Compare commits
11 Commits
6ef57792ce
...
328f7cb712
Author | SHA1 | Date | |
---|---|---|---|
328f7cb712 | |||
84dbfc7234 | |||
48cc6b1302 | |||
a6007ee89a | |||
192a37d93f | |||
b17f77b22a | |||
007978a0f8 | |||
80b21ac231 | |||
0a32d60827 | |||
26a50fb972 | |||
964ee17540 |
@ -28,6 +28,7 @@ public:
|
||||
pop_carry_over = -1;
|
||||
pop_carry_over_option_id = -1;
|
||||
pop_prepaid_option_id = -1;
|
||||
pop_prepay_option_id = -1;
|
||||
pop_truncate_last_interpolation_step = false;
|
||||
pop_accumulate_prices = false;
|
||||
pop_accumulate_durations = false;
|
||||
@ -61,7 +62,8 @@ public:
|
||||
int pop_carry_over;
|
||||
int pop_carry_over_option_id;
|
||||
bool pop_truncate_last_interpolation_step;
|
||||
int pop_prepaid_option_id;
|
||||
int pop_prepaid_option_id; // deprecated
|
||||
int pop_prepay_option_id;
|
||||
bool pop_carry_over_target;
|
||||
int pop_carry_over_time_range_id;
|
||||
int pop_carry_over_start_time_range;
|
||||
|
68
library/include/mobilisis/tariff_prepay.h
Normal file
68
library/include/mobilisis/tariff_prepay.h
Normal file
@ -0,0 +1,68 @@
|
||||
#ifndef TARIFF_PREPAY_H_INCLUDED
|
||||
#define TARIFF_PREPAY_H_INCLUDED
|
||||
|
||||
#include <QTime>
|
||||
|
||||
struct ATBPrepay {
|
||||
struct week {
|
||||
int day;
|
||||
bool prepaid; // yes/no
|
||||
QTime start; // only valid if prepaid == true
|
||||
QTime end;
|
||||
int duration;
|
||||
} prepay[8];
|
||||
|
||||
int id;
|
||||
|
||||
friend QDebug operator<<(QDebug debug, ATBPrepay const &pp) {
|
||||
QDebugStateSaver saver(debug);
|
||||
|
||||
debug.nospace()
|
||||
<< " id:" << pp.id << "\n"
|
||||
<< " **** Monday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Monday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Monday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Monday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Monday].prepaid << "\n"
|
||||
<< " **** Tuesday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Tuesday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Tuesday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Tuesday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Tuesday].prepaid << "\n"
|
||||
<< " **** Wednesday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Wednesday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Wednesday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Wednesday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Wednesday].prepaid << "\n"
|
||||
<< " **** Thursday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Thursday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Thursday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Thursday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Thursday].prepaid << "\n"
|
||||
<< " **** Friday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Friday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Friday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Friday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Friday].prepaid << "\n"
|
||||
<< " **** Saturday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Saturday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Saturday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Saturday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Saturday].prepaid << "\n"
|
||||
<< " **** Sunday **** \n"
|
||||
<< " day: " << pp.prepay[(int)Qt::Sunday].day << "\n"
|
||||
<< " start: " << pp.prepay[(int)Qt::Sunday].start.toString(Qt::ISODate) << "\n"
|
||||
<< " end: " << pp.prepay[(int)Qt::Sunday].end.toString(Qt::ISODate) << "\n"
|
||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
||||
<< " prepaid: " << pp.prepay[(int)Qt::Sunday].prepaid << "\n";
|
||||
|
||||
return debug;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TARIFF_CARRYOVER_H_INCLUDED
|
@ -6,7 +6,7 @@
|
||||
#include <QDebugStateSaver>
|
||||
|
||||
struct ATBTimeStepConfig {
|
||||
enum class TimeStepConfig {STATIC=1, DYNAMIC=2};
|
||||
enum class TimeStepConfig {STATIC=1, DYNAMIC=2, RECOMPUTE_SOME=3};
|
||||
|
||||
ATBTimeStepConfig() = default;
|
||||
int tsconfig_id;
|
||||
|
@ -89,12 +89,14 @@ HEADERS += \
|
||||
include/mobilisis/tariff_interpolation.h \
|
||||
include/mobilisis/tariff_prepaid.h \
|
||||
include/mobilisis/tariff_carryover.h \
|
||||
include/mobilisis/tariff_prepay.h \
|
||||
include/mobilisis/tariff_global_defines.h
|
||||
|
||||
OTHER_FILES += src/main.cpp \
|
||||
../tariffs/tariff_korneuburg.json \
|
||||
../tariffs/tariff_linsinger_maschinenbau.json \
|
||||
../tariffs/tariff_naz.json
|
||||
# OTHER_FILES += src/main.cpp \
|
||||
# ../tariffs/tariff_korneuburg.json \
|
||||
# ../tariffs/tariff_linsinger_maschinenbau.json \
|
||||
# ../tariffs/tariff_naz.json \
|
||||
# /home/linux/customer_502/etc/psa_tariff/tariff03.json
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
|
@ -327,6 +327,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
|
||||
maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
|
||||
} else if (paymentMethodId == PaymentMethod::Degressive) {
|
||||
maxPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
|
||||
} else { // PaymentMethod::Linear -> e.g. szeged
|
||||
int const key = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time; // maxTime is given in minutes
|
||||
@ -768,7 +770,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
return calcState;
|
||||
}
|
||||
|
||||
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff);
|
||||
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex, start_parking_time_);
|
||||
Q_UNUSED(tlist);
|
||||
|
||||
// compute cost (price)
|
||||
|
@ -159,7 +159,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
|
||||
}
|
||||
|
||||
if (prepaid == false) {
|
||||
int const pop_time_step_config = cfg->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
|
||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::RECOMPUTE_SOME || prepaid == false) {
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
||||
int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||
@ -181,8 +182,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
price = pra_price;
|
||||
}
|
||||
|
||||
// qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
|
||||
// qCritical() << DBG_HEADER << " duration id" << durationId;
|
||||
//qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
|
||||
//qCritical() << DBG_HEADER << " duration id" << durationId;
|
||||
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
if (search != cfg->Duration.end()) {
|
||||
@ -191,7 +192,9 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
ATBDuration duration = search->second;
|
||||
|
||||
if (pop_accumulate_prices) {
|
||||
uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||
int32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||
|
||||
// qCritical() << DBG_HEADER << " duration unit" << durationUnit;
|
||||
|
||||
new_price += pra_price;
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") old price" << price << ", new_price:" << new_price;
|
||||
@ -2770,6 +2773,165 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::RECOMPUTE_SOME) {
|
||||
// some durations / timesteps have to be recomputed
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::RECOMPUTE_SOME";
|
||||
int size = m_timeSteps.size();
|
||||
|
||||
while (size <= paymentOptionIndex) {
|
||||
m_timeSteps.push_back(QList<int>());
|
||||
size = m_timeSteps.size();
|
||||
}
|
||||
|
||||
int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||
|
||||
m_timeSteps[paymentOptionIndex].clear();
|
||||
Configuration::TariffDurationType::iterator prev_it = cfg->Duration.end();
|
||||
|
||||
start = s;
|
||||
start.setTime(QTime(s.time().hour(), s.time().minute(), 0));
|
||||
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
|
||||
|
||||
for (Configuration::TariffDurationType::iterator it = cfg->Duration.begin();
|
||||
it != cfg->Duration.end();
|
||||
++it) {
|
||||
it->second.pun_duration = it->second.pun_duration_saved;
|
||||
if (it->second.pun_requires_change) {
|
||||
if (it->second.pun_netto && !it->second.pun_brutto) {
|
||||
|
||||
int weekDay = start.date().dayOfWeek();
|
||||
bool casePrepay = false;
|
||||
if (m_timeSteps[paymentOptionIndex].isEmpty()) {
|
||||
// handle possible prepay-condition, which applies only
|
||||
// for the very first step
|
||||
|
||||
int const pop_prepay_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_prepay_option_id;
|
||||
QDateTime prepayStart(start);
|
||||
QDateTime prepayEnd(start);
|
||||
|
||||
prepayStart.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].start);
|
||||
prepayEnd.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].end);
|
||||
|
||||
if (start <= prepayEnd) {
|
||||
prepayStart = prepayStart.addDays(-1);
|
||||
} else {
|
||||
prepayEnd = prepayEnd.addDays(1);
|
||||
}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << start.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << prepayStart.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << prepayEnd.toString(Qt::ISODate);
|
||||
|
||||
if (prepayStart <= start && start <= prepayEnd) {
|
||||
it->second.pun_duration = start.secsTo(prepayEnd) / 60;
|
||||
it->second.pun_duration += it->second.pun_duration_saved ;
|
||||
casePrepay = true;
|
||||
}
|
||||
//if (start >= prepayStart && ) {
|
||||
// it->second.pun_duration = start.secsTo(prepayEnd) / 60;
|
||||
// it->second.pun_duration += it->second.pun_duration_saved ;
|
||||
// casePrepay = true;
|
||||
//}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << it->second.pun_duration;
|
||||
}
|
||||
|
||||
if (!casePrepay) {
|
||||
// handle possible carryover-condition
|
||||
int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||
QDateTime carryOverStart(start);
|
||||
QDateTime carryOverEnd(start);
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << carryOverStart.toString(Qt::ISODate);
|
||||
|
||||
carryOverStart.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start);
|
||||
carryOverEnd.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end);
|
||||
|
||||
//while (carryOverStart > carryOverEnd) {
|
||||
// carryOverEnd = carryOverEnd.addDays(1);
|
||||
//}
|
||||
|
||||
if (start <= carryOverEnd) {
|
||||
carryOverStart = carryOverStart.addDays(-1);
|
||||
} else {
|
||||
carryOverEnd = carryOverEnd.addDays(1);
|
||||
}
|
||||
|
||||
int durationInSecs = it->second.pun_duration_saved * 60;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << durationInSecs;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << start.addSecs(durationInSecs).toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << carryOverStart.toString(Qt::ISODate);
|
||||
|
||||
it->second.pun_duration = it->second.pun_duration_saved;
|
||||
if (start >= carryOverStart) {
|
||||
it->second.pun_duration += start.secsTo(carryOverEnd) / 60;
|
||||
} else {
|
||||
// start < carryOverStart
|
||||
if (start.addSecs(durationInSecs) >= carryOverStart) {
|
||||
// cross carry over section
|
||||
it->second.pun_next_step_correction = carryOverStart.secsTo(carryOverEnd) / 60;
|
||||
it->second.pun_duration += it->second.pun_next_step_correction;
|
||||
prev_it = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pop_accumulate_durations) {
|
||||
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
||||
int d = m_timeSteps[paymentOptionIndex].last();
|
||||
m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
|
||||
} else {
|
||||
m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< "no change required, but set to brutto, which does not have to be changed";
|
||||
}
|
||||
} else {
|
||||
if (it->second.pun_fixed) { // no change required: must be true
|
||||
if (it->second.pun_brutto) { // no handling for prepay and carry-over
|
||||
if (pop_accumulate_durations) {
|
||||
int correction = 0;
|
||||
if (prev_it != cfg->Duration.end()) {
|
||||
correction = prev_it->second.pun_next_step_correction;
|
||||
prev_it->second.pun_next_step_correction = 0;
|
||||
}
|
||||
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
||||
int d = m_timeSteps[paymentOptionIndex].last();
|
||||
it->second.pun_duration -= correction;
|
||||
m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
|
||||
} else {
|
||||
it->second.pun_duration -= correction;
|
||||
m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (it->second.pun_netto) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "TODO";
|
||||
}
|
||||
} else {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "fixed is false, but no change required";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
|
||||
QDateTime nextTime = start;
|
||||
// nextTime.setTime(QTime(0, 0, 0));
|
||||
int const secs = m_timeSteps[paymentOptionIndex][i] * 60;
|
||||
nextTime = nextTime.addSecs(secs);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") step"
|
||||
<< i << secs << m_timeSteps[0][i] << "->" << nextTime.toString(Qt::ISODate);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::STATIC";
|
||||
|
||||
@ -2788,7 +2950,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "tariff_business_hours.h"
|
||||
#include "tariff_global_defines.h"
|
||||
#include "tariff_carryover.h"
|
||||
#include "tariff_prepay.h"
|
||||
#include "tariff_global_defines.h"
|
||||
|
||||
#include <QString>
|
||||
@ -35,6 +36,7 @@ MemberType Configuration::IdentifyJsonMember(const char* member_name)
|
||||
if (strcmp(member_name, "Interpolation") == 0) return MemberType::InterpolationType;
|
||||
if (strcmp(member_name, "Prepaid") == 0) return MemberType::PrepaidType;
|
||||
if (strcmp(member_name, "CarryOver") == 0) return MemberType::CarryOverType;
|
||||
if (strcmp(member_name, "PrepaidOption") == 0) return MemberType::PrepaidOptionType;
|
||||
else return MemberType::UnknownType;
|
||||
}
|
||||
|
||||
@ -108,6 +110,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
ATBInterpolation TariffInterpolation;
|
||||
ATBPrepaid TariffPrepaidOption;
|
||||
ATBCarryOver TariffCarryOver;
|
||||
ATBPrepay TariffPrepayOption;
|
||||
|
||||
MemberType mb_type = MemberType::UnknownType;
|
||||
this->currentPaymentOptions.clear();
|
||||
@ -171,6 +174,61 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
{
|
||||
case MemberType::UnknownType:
|
||||
break;
|
||||
case MemberType::PrepaidOptionType: {
|
||||
if (QString(inner_obj_name) == QString("prepaid_option_id")) {
|
||||
if (k->value.IsInt()) {
|
||||
int const &x = k->value.GetInt();
|
||||
TariffPrepayOption.id = x;
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("prepaid_option_week")) {
|
||||
if (k->value.IsArray()) {
|
||||
auto days = k->value.GetArray();
|
||||
for (rapidjson::SizeType j=0; j < days.Size(); ++j) {
|
||||
if (days[j].IsObject()) {
|
||||
auto weekday = days[j].GetObject();
|
||||
for (auto w = weekday.MemberBegin(); w != weekday.MemberEnd(); ++w) {
|
||||
int day = j+1; // 8 entries
|
||||
QString member(QString::fromStdString(w->name.GetString()));
|
||||
if (member == "prepaid_option_day") {
|
||||
if (w->value.IsInt()) {
|
||||
rapidjson::SizeType const d = w->value.GetInt();
|
||||
if (d != (j+1)) {
|
||||
qCritical() << "ERROR: misconfigured jsonfile" << d << "!=" << (j+1);
|
||||
}
|
||||
TariffPrepayOption.prepay[day].day = day;
|
||||
}
|
||||
} else
|
||||
if (member == "prepaid_option_duration") {
|
||||
if (w->value.IsInt()) {
|
||||
TariffPrepayOption.prepay[day].duration = w->value.GetInt();
|
||||
}
|
||||
} else
|
||||
if (member == "prepaid_option_prepaid") {
|
||||
if (w->value.IsBool()) {
|
||||
bool b = w->value.GetBool();
|
||||
TariffPrepayOption.prepay[day].prepaid = b;
|
||||
}
|
||||
} else
|
||||
if (member == "prepaid_option_start") {
|
||||
if (w->value.IsString()) {
|
||||
QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
|
||||
TariffPrepayOption.prepay[day].start = t;
|
||||
}
|
||||
} else
|
||||
if (member == "prepaid_option_end") {
|
||||
if (w->value.IsString()) {
|
||||
QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
|
||||
TariffPrepayOption.prepay[day].end = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} break;
|
||||
case MemberType::CarryOverType: {
|
||||
if (QString(inner_obj_name) == QString("carry_over_id")) {
|
||||
if (k->value.IsInt()) {
|
||||
@ -231,6 +289,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
}
|
||||
}
|
||||
} break;
|
||||
// deprecated
|
||||
case MemberType::PrepaidType: {
|
||||
if (QString(inner_obj_name) == QString("prepaid_id")) {
|
||||
if (k->value.IsInt()) {
|
||||
@ -622,8 +681,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
|
||||
} else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
|
||||
this->currentPaymentOptions.last().pop_min_price = k->value.GetDouble();
|
||||
} else if (strcmp(inner_obj_name, "pop_prepaid_option_id") == 0) {
|
||||
} else if (strcmp(inner_obj_name, "pop_prepaid_option_id") == 0) { // deprecated
|
||||
this->currentPaymentOptions.last().pop_prepaid_option_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_prepay_option_id") == 0) {
|
||||
this->currentPaymentOptions.last().pop_prepay_option_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_truncate_last_interpolation_step") == 0) {
|
||||
this->currentPaymentOptions.last().pop_truncate_last_interpolation_step = k->value.GetBool();
|
||||
} else if (strcmp(inner_obj_name, "pop_accumulate_prices") == 0) {
|
||||
@ -721,6 +782,26 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
} else if (strcmp(inner_obj_name, "pun_duration_min") == 0) Duration.pun_duration_min = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pun_duration_max") == 0) Duration.pun_duration_max = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pun_interpolation_id") == 0) Duration.pun_interpolation_id = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pun_netto") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_netto = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
else if (strcmp(inner_obj_name, "pun_brutto") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_brutto = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
else if (strcmp(inner_obj_name, "pun_fixed") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_fixed = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
else if (strcmp(inner_obj_name, "pun_requires_change") == 0) {
|
||||
if (k->value.IsBool()) {
|
||||
Duration.pun_requires_change = k->value.GetBool();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MemberType::SpecialDaysWorktimeType:
|
||||
if (strcmp(inner_obj_name, "pedwt_id") == 0) SpecialDaysWorktime.pedwt_id = k->value.GetInt();
|
||||
@ -839,6 +920,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
cfg->TariffCarryOverOptions.insert(pair<int, ATBCarryOver>(TariffCarryOver.id, TariffCarryOver));
|
||||
// qCritical() << TariffCarryOver;
|
||||
break;
|
||||
case MemberType::PrepaidOptionType:
|
||||
cfg->TariffPrepayOptions.insert(pair<int, ATBPrepay>(TariffPrepayOption.id, TariffPrepayOption));
|
||||
qCritical() << TariffPrepayOption;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -741,7 +741,8 @@ int main() {
|
||||
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json");
|
||||
}
|
||||
if (zone == 3) {
|
||||
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json");
|
||||
//input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json");
|
||||
input.open("/home/linux/customer_502/etc/psa_tariff/tariff03.json");
|
||||
}
|
||||
|
||||
std::stringstream sstr;
|
||||
@ -900,7 +901,7 @@ int main() {
|
||||
int Down = 0;
|
||||
int Up = 1;
|
||||
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
QDateTime start = QDateTime::currentDateTime();
|
||||
int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
|
||||
if (paymentOptionIndex != 0) {
|
||||
@ -913,17 +914,57 @@ int main() {
|
||||
//QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
|
||||
|
||||
QDateTime end;
|
||||
CalcState calcState;
|
||||
|
||||
QDateTime s(QDateTime::currentDateTime());
|
||||
s.setTime(QTime(12, 0, 0));
|
||||
s.setTime(QTime(18, 0, 0));
|
||||
|
||||
int minimal_parking_price = get_minimal_parkingprice(&cfg,
|
||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
|
||||
paymentOptionIndex, s);
|
||||
pop_min_time = get_minimal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
|
||||
|
||||
pop_min_price = get_minimal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex, s);
|
||||
pop_max_price = get_maximal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
|
||||
|
||||
pop_daily_card_price = cfg.getPaymentOptions(paymentOptionIndex).pop_daily_card_price;
|
||||
|
||||
int h = pop_min_time / 60;
|
||||
int m = pop_min_time % 60;
|
||||
qCritical().noquote() << QString(" pop_min_time %1 (%2h, %3m)").arg(pop_min_time).arg(h).arg(m);
|
||||
|
||||
h = pop_max_time / 60;
|
||||
m = pop_max_time % 60;
|
||||
qCritical().noquote()
|
||||
<< QString(" pop_max_time %1 (%2h, %3m)").arg(pop_max_time).arg(h).arg(m);
|
||||
|
||||
qCritical() << " pop_min_price " << pop_min_price;
|
||||
qCritical() << " pop_max_price " << pop_max_price;
|
||||
qCritical() << "pop_daily_card_price " << pop_daily_card_price;
|
||||
|
||||
CalcState calcState;
|
||||
|
||||
#if 0
|
||||
for (int i = 1; i < 11; ++i) {
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)i*200,
|
||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
||||
qCritical() << "RUN" << i << ": start" << s.toString(Qt::ISODate)
|
||||
<< ": price" << i*200 << "->" << end.toString(Qt::ISODate) << calcState.toString();
|
||||
}
|
||||
#else
|
||||
struct price_t price;
|
||||
int netto_parking_time = 1440;
|
||||
|
||||
start = s;
|
||||
qCritical() << "RUN" << 0 << ": start" << s.toString(Qt::ISODate);
|
||||
|
||||
calcState = compute_price_for_parking_ticket(&cfg, start, netto_parking_time,
|
||||
end, &price,
|
||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
||||
qCritical() << "RUN" << 0 << ": start" << start.toString(Qt::ISODate)
|
||||
<< ": price for netto-time" << netto_parking_time
|
||||
<< "->" << price.netto << "->" << end.toString(Qt::ISODate) << calcState.toString();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
qCritical() << "minimal parking price" << minimal_parking_price;
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
@ -932,11 +973,11 @@ int main() {
|
||||
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
||||
}
|
||||
|
||||
#else
|
||||
s.setTime(QTime(15, 0, 0));
|
||||
// #else
|
||||
s.setTime(QTime(12, 0, 0));
|
||||
|
||||
minimal_parking_price = get_minimal_parkingprice(&cfg,
|
||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
|
||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS),
|
||||
paymentOptionIndex, s);
|
||||
|
||||
qCritical() << "minimal parking price" << minimal_parking_price;
|
||||
@ -944,7 +985,7 @@ int main() {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)minimal_parking_price + i*800,
|
||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
|
||||
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user