Compare commits
4 Commits
master
...
praesentat
Author | SHA1 | Date | |
---|---|---|---|
ed6d355517 | |||
f1f033d1cd | |||
f547f563bf | |||
141d3281b7 |
@ -277,6 +277,12 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff,
|
||||
void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff);
|
||||
int CALCULATE_LIBRARY_API get_zone_nr(int zone = -1);
|
||||
|
||||
|
||||
int CALCULATE_LIBRARY_API isOutOfService(Configuration const *cfg,
|
||||
QDateTime const &dt);
|
||||
|
||||
int CALCULATE_LIBRARY_API isOutOfService(QDateTime const &dt);
|
||||
|
||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
|
||||
int UpDown, PermitType const &permitType);
|
||||
|
||||
|
@ -34,6 +34,8 @@
|
||||
|
||||
#include <QVector>
|
||||
#include <optional>
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
|
||||
using namespace std;
|
||||
using namespace rapidjson;
|
||||
@ -83,7 +85,11 @@ public:
|
||||
TariffOutOfServiceType TariffOutOfServices;
|
||||
ATBTariffPrepaidType TariffPrepaids;
|
||||
ATBTariffCarryOverType TariffCarryOvers;
|
||||
QStringList TariffIncludes;
|
||||
QList<QPair<QString, QString>> TariffIncludes;
|
||||
|
||||
QTime ValidFrom;
|
||||
int ValidForWeekDay{};
|
||||
QStringList tariffFileName{};
|
||||
|
||||
/// <summary>
|
||||
/// Parse JSON string
|
||||
@ -124,8 +130,8 @@ public:
|
||||
std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
|
||||
std::optional<QVector<ATBWeekDaysWorktime>> getAllWeekDayWorkTimes();
|
||||
|
||||
QStringList const &getTariffIncludes() const { return TariffIncludes; }
|
||||
QStringList &getTariffIncludes() { return TariffIncludes; }
|
||||
QList<QPair<QString, QString>> const &getTariffIncludes() const { return TariffIncludes; }
|
||||
QList<QPair<QString, QString>> &getTariffIncludes() { return TariffIncludes; }
|
||||
|
||||
std::optional<QDateTime> prepaidStart(QDateTime const &start, int prepaid_option_id);
|
||||
int getPaymentOptionIndex(PERMIT_TYPE permitType);
|
||||
|
@ -21,6 +21,9 @@ enum class PERMIT_TYPE : quint8 {
|
||||
DAY_TICKET_BUS=14,
|
||||
DAY_TICKET_CAMPER=15,
|
||||
FREE_TICKET=16,
|
||||
|
||||
TEST_PRODUCT_1=17,
|
||||
TEST_PRODUCT_2=18,
|
||||
PRODUCT_MAX
|
||||
};
|
||||
|
||||
@ -78,6 +81,12 @@ struct PermitType {
|
||||
case 16:
|
||||
m_permitType = PERMIT_TYPE::FREE_TICKET;
|
||||
break;
|
||||
case 17:
|
||||
m_permitType = PERMIT_TYPE::TEST_PRODUCT_1;
|
||||
break;
|
||||
case 18:
|
||||
m_permitType = PERMIT_TYPE::TEST_PRODUCT_2;
|
||||
break;
|
||||
default:
|
||||
m_permitType = PERMIT_TYPE::INVALID;
|
||||
}
|
||||
@ -123,6 +132,10 @@ struct PermitType {
|
||||
return 15;
|
||||
case PERMIT_TYPE::FREE_TICKET:
|
||||
return 16;
|
||||
case PERMIT_TYPE::TEST_PRODUCT_1:
|
||||
return 17;
|
||||
case PERMIT_TYPE::TEST_PRODUCT_2:
|
||||
return 18;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -177,6 +190,12 @@ struct PermitType {
|
||||
} else
|
||||
if (permitTypeStr == "FREE_TICKET") {
|
||||
return PERMIT_TYPE::FREE_TICKET;
|
||||
} else
|
||||
if (permitTypeStr == "TEST_PRODUCT_1") {
|
||||
return PERMIT_TYPE::TEST_PRODUCT_1;
|
||||
} else
|
||||
if (permitTypeStr == "TEST_PRODUCT_2") {
|
||||
return PERMIT_TYPE::TEST_PRODUCT_2;
|
||||
}
|
||||
|
||||
return PERMIT_TYPE::INVALID;
|
||||
@ -216,6 +235,10 @@ struct PermitType {
|
||||
return QString("DAY_TICKET_CAMPER");
|
||||
case PERMIT_TYPE::FREE_TICKET:
|
||||
return QString("FREE_TICKET");
|
||||
case PERMIT_TYPE::TEST_PRODUCT_1:
|
||||
return QString("TEST_PRODUCT_1");
|
||||
case PERMIT_TYPE::TEST_PRODUCT_2:
|
||||
return QString("TEST_PRODUCT_2");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -256,6 +279,10 @@ struct PermitType {
|
||||
return QString("DAY_TICKET_CAMPER");
|
||||
case PERMIT_TYPE::FREE_TICKET:
|
||||
return QString("FREE_TICKET");
|
||||
case PERMIT_TYPE::TEST_PRODUCT_1:
|
||||
return QString("TEST_PRODUCT_1");
|
||||
case PERMIT_TYPE::TEST_PRODUCT_2:
|
||||
return QString("TEST_PRODUCT_2");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -33,6 +33,101 @@ QString const CalcState::SUCCESS_MAXPRICE = "SUCCESS_MAXPRICE";
|
||||
|
||||
|
||||
static std::map<PERMIT_TYPE, std::unique_ptr<parking_tariff_t>> tariffs;
|
||||
static QDateTime start_ = QDateTime::currentDateTime();
|
||||
static Configuration const *current_tariff{nullptr};
|
||||
|
||||
int CALCULATE_LIBRARY_API isOutOfService(QDateTime const &dt) {
|
||||
if (!current_tariff) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "NO CURRENT TARIFF";
|
||||
return false;
|
||||
}
|
||||
|
||||
// L201
|
||||
if (current_tariff->tariffFileName.contains("tariff01")) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "NO";
|
||||
return false;
|
||||
} else
|
||||
// L264
|
||||
if (current_tariff->tariffFileName.contains("tariff02") ||
|
||||
current_tariff->tariffFileName.contains("tariff02_1700_2300") ||
|
||||
current_tariff->tariffFileName.contains("tariff02_1900_2300")) {
|
||||
// feiertage
|
||||
QDate const &d = dt.date();
|
||||
if (d.toString(Qt::ISODate) == "2025-06-09"
|
||||
|| d.toString(Qt::ISODate) == "2025-06-19"
|
||||
|| d.toString(Qt::ISODate) == "2025-08-15"
|
||||
|| d.toString(Qt::ISODate) == "2025-10-03"
|
||||
|| d.toString(Qt::ISODate) == "2025-11-01"
|
||||
|| d.toString(Qt::ISODate) == "2025-12-25"
|
||||
|| d.toString(Qt::ISODate) == "2025-12-26") {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||
return true;
|
||||
}
|
||||
|
||||
int const day = d.dayOfWeek();
|
||||
if (day == 7) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dt.time() >= QTime::fromString("23:00:00", Qt::ISODate)) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||
return true;
|
||||
}
|
||||
|
||||
} else
|
||||
// H242
|
||||
if (current_tariff->tariffFileName.contains("tariff03") ||
|
||||
current_tariff->tariffFileName.contains("tariff03_H242_sat")) {
|
||||
// feiertage
|
||||
QDate const &d = dt.date();
|
||||
if (d.toString(Qt::ISODate) == "2025-06-09"
|
||||
|| d.toString(Qt::ISODate) == "2025-06-19"
|
||||
|| d.toString(Qt::ISODate) == "2025-08-15"
|
||||
|| d.toString(Qt::ISODate) == "2025-10-03"
|
||||
|| d.toString(Qt::ISODate) == "2025-11-01"
|
||||
|| d.toString(Qt::ISODate) == "2025-12-25"
|
||||
|| d.toString(Qt::ISODate) == "2025-12-26") {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||
return true;
|
||||
}
|
||||
|
||||
int const day = d.dayOfWeek();
|
||||
if (day == 7) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||
return true;
|
||||
}
|
||||
|
||||
QTime const &t = dt.time();
|
||||
if (day <= 5) {
|
||||
if (t < QTime::fromString("18:00:00", Qt::ISODate)) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (day == 6) {
|
||||
if (t < QTime::fromString("14:00:00", Qt::ISODate)) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (t >= QTime::fromString("23:00:00", Qt::ISODate)) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "NO";
|
||||
return false;
|
||||
}
|
||||
|
||||
int CALCULATE_LIBRARY_API isOutOfService(Configuration const *cfg,
|
||||
QDateTime const &dt) {
|
||||
Q_UNUSED(cfg);
|
||||
return isOutOfService(dt);
|
||||
}
|
||||
|
||||
|
||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
|
||||
return Calculator::GetInstance().GetTimeSteps(cfg);
|
||||
@ -41,17 +136,82 @@ QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
||||
PERMIT_TYPE permitType,
|
||||
int paymentOptionIndex) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
int minTime = 0;
|
||||
|
||||
|
||||
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||
// which means the code below will be executed only in such a case.
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
Configuration *c = tariffs[permitType].get();
|
||||
if (c && c != cfg) {
|
||||
cfg = c;
|
||||
Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (cfg != c1 && cfg != c2) {
|
||||
cfg = c;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
|
||||
Configuration *c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
if (c1 && c1->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << start_.time() << c1->ValidFrom;
|
||||
if (start_.time() >= c1->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (c2 && c2 != cfg) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c1 && c1 != cfg) {
|
||||
cfg = c1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (c1 && c1->ValidForWeekDay == start_.date().dayOfWeek()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c1 && c1 != cfg) {
|
||||
cfg = c1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
|
||||
Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (c2 && c2->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (start_.time() >= c2->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c2 && c2 != cfg) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
cfg = c2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = cfg;
|
||||
|
||||
int weekDay = start_.date().dayOfWeek();
|
||||
qCritical() << __func__ << __LINE__ << cfg << "CCCCCC week" << (int)permitType << weekDay;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->WeekDays.equal_range((Qt::DayOfWeek)weekDay); itr != rangeEnd; ++itr) {
|
||||
ATBWeekDay const &wd = itr->second;
|
||||
|
||||
minTime = wd.getTariffSettings().m_min_time;
|
||||
qCritical() << __func__ << __LINE__ << "CCCCCC min_time" << (int)permitType << minTime;
|
||||
if (minTime < 0) {
|
||||
return minTime;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
paymentOptionIndex = getPaymentOptionIndex(*cfg);
|
||||
if (paymentOptionIndex == -1) {
|
||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||
@ -82,7 +242,7 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
||||
minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
|
||||
}
|
||||
|
||||
qCritical() << "minTime" << minTime;
|
||||
qCritical() << __func__ << ":" << __LINE__ << " minTime" << minTime;
|
||||
return minTime;
|
||||
}
|
||||
|
||||
@ -90,14 +250,63 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
PERMIT_TYPE permitType,
|
||||
int paymentOptionIndex) {
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||
// which means the code below will be executed only in such a case.
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
Configuration *c = tariffs[permitType].get();
|
||||
if (c && c != cfg) {
|
||||
cfg = c;
|
||||
Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (cfg != c1 && cfg != c2) {
|
||||
cfg = c;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
|
||||
Configuration *c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
if (c1 && c1->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << start_.time() << c1->ValidFrom;
|
||||
if (start_.time() >= c1->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (c2 && c2 != cfg) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c1 && c1 != cfg) {
|
||||
cfg = c1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (c1 && c1->ValidForWeekDay == start_.date().dayOfWeek()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c1 && c1 != cfg) {
|
||||
cfg = c1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
|
||||
Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (c2 && c2->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (start_.time() >= c2->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c2 && c2 != cfg) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
cfg = c2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = cfg;
|
||||
|
||||
paymentOptionIndex = getPaymentOptionIndex(*cfg);
|
||||
if (paymentOptionIndex == -1) {
|
||||
@ -120,6 +329,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
||||
}
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << " maxTime" << maxTime;
|
||||
|
||||
return maxTime;
|
||||
}
|
||||
|
||||
@ -127,6 +338,8 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
PERMIT_TYPE permitType,
|
||||
int paymentOptionIndex,
|
||||
QDateTime const &start) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
start_ = start;
|
||||
int minPrice = -1;
|
||||
|
||||
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||
@ -134,9 +347,57 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
Configuration *c = tariffs[permitType].get();
|
||||
if (c && c != cfg) {
|
||||
cfg = c;
|
||||
Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (cfg != c1 && cfg != c2) {
|
||||
cfg = c;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
|
||||
Configuration *c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
if (c1 && c1->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << start_.time() << c1->ValidFrom;
|
||||
if (start_.time() >= c1->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (c2 && c2 != cfg) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c1 && c1 != cfg) {
|
||||
cfg = c1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (c1 && c1->ValidForWeekDay == start_.date().dayOfWeek()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c1 && c1 != cfg) {
|
||||
cfg = c1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
|
||||
Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (c2 && c2->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (start_.time() >= c2->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c2 && c2 != cfg) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
cfg = c2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = cfg;
|
||||
|
||||
if ((paymentOptionIndex = getPaymentOptionIndex(*cfg, start)) == -1) {
|
||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||
@ -194,6 +455,7 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << " minPrice" << minPrice;
|
||||
return minPrice;
|
||||
}
|
||||
|
||||
@ -202,15 +464,23 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
||||
QDateTime const &start,
|
||||
QDateTime *productStart,
|
||||
QDateTime *productEnd) {
|
||||
start_ = start;
|
||||
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||
// which means the code below will be executed only in such a case.
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
Configuration *c = tariffs[permitType].get();
|
||||
if (c && c != cfg) {
|
||||
cfg = c;
|
||||
Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (cfg != c1 && cfg != c2) {
|
||||
cfg = c;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = cfg;
|
||||
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
} break;
|
||||
@ -372,6 +642,7 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
||||
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
||||
PERMIT_TYPE permitType,
|
||||
int paymentOptionIndex) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
int maxPrice = -1;
|
||||
|
||||
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||
@ -379,9 +650,57 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
Configuration *c = tariffs[permitType].get();
|
||||
if (c && c != cfg) {
|
||||
cfg = c;
|
||||
Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (cfg != c1 && cfg != c2) {
|
||||
cfg = c;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
|
||||
Configuration *c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
if (c1 && c1->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << start_.time() << c1->ValidFrom;
|
||||
if (start_.time() >= c1->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (c2 && c2 != cfg) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c1 && c1 != cfg) {
|
||||
cfg = c1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (c1 && c1->ValidForWeekDay == start_.date().dayOfWeek()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c1 && c1 != cfg) {
|
||||
cfg = c1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
|
||||
Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (c2 && c2->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (start_.time() >= c2->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (c2 && c2 != cfg) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
cfg = c2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = cfg;
|
||||
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
|
||||
@ -441,6 +760,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
||||
default: ;
|
||||
}
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << " maxPrice" << maxPrice;
|
||||
return maxPrice;
|
||||
}
|
||||
|
||||
@ -508,6 +828,9 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char cons
|
||||
qCritical() << " ... error parsing tariff";
|
||||
return calcState.set(CalcState::State::ERROR_PARSING_TARIFF);
|
||||
}
|
||||
QFileInfo fi(confFile);
|
||||
(*tariff)->tariffFileName << fi.baseName();
|
||||
current_tariff = *tariff;
|
||||
} else {
|
||||
delete *tariff;
|
||||
*tariff = nullptr;
|
||||
@ -520,17 +843,33 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char cons
|
||||
if ((*tariff)->TariffIncludes.size() > 0) {
|
||||
qCritical() << "init_tariff: TariffIncludes" << (*tariff)->TariffIncludes;
|
||||
for (int i = 0 ; i < (*tariff)->TariffIncludes.size(); ++i) {
|
||||
QFile f(QString("/etc/psa_tariff/%1").arg((*tariff)->TariffIncludes.at(i)));
|
||||
QPair<QString, QString> const &p = (*tariff)->TariffIncludes.at(i);
|
||||
|
||||
QFile f(QString("/etc/psa_tariff/%1").arg((*tariff)->TariffIncludes.at(i).second));
|
||||
if (f.exists() &&
|
||||
f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
|
||||
QString json = f.readAll();
|
||||
std::unique_ptr<parking_tariff_t> t = std::make_unique<parking_tariff_t>();
|
||||
|
||||
|
||||
if (! t->ParseJson(t.get(), json.toStdString().c_str())) {
|
||||
qCritical() << " ... error parsing tariff in" << f.fileName();
|
||||
qCritical() << " ... json" << json;
|
||||
} else {
|
||||
QFileInfo fi(p.second.trimmed());
|
||||
t->tariffFileName << fi.baseName();
|
||||
QTime validFrom(QTime::fromString(p.first, Qt::ISODate));
|
||||
if (validFrom.isValid()) {
|
||||
t->ValidFrom = validFrom;
|
||||
}
|
||||
QString validForWeekDay(p.first);
|
||||
qCritical() << " ... valid for weekday" << validForWeekDay;
|
||||
if (validForWeekDay.contains("Sat")) {
|
||||
t->ValidForWeekDay = (int)Qt::Saturday;
|
||||
qCritical() << " ... valid for weekday" << validForWeekDay;
|
||||
}
|
||||
|
||||
PERMIT_TYPE pt = static_cast<PERMIT_TYPE>(t->getPaymentOptions().pop_product_id);
|
||||
if (tariffs.count(pt) == 0) {
|
||||
const auto [it, success] = tariffs.insert(std::make_pair(pt, std::move(t)));
|
||||
@ -556,7 +895,64 @@ void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff) {
|
||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
|
||||
int UpDown, PermitType const &permitType)
|
||||
{
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
parking_tariff_t *t = tariffs[permitType].get();
|
||||
if (t && t != tariff) {
|
||||
parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (tariff != t1 && tariff != t2) {
|
||||
tariff = t;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
|
||||
parking_tariff_t *t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
if (t1 && t1->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << start_.time() << t1->ValidFrom;
|
||||
if (start_.time() >= t1->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
parking_tariff_t *t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (t2 && t2 != tariff) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (t1 && t1 != tariff) {
|
||||
tariff = t1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (t1 && t1->ValidForWeekDay == start_.date().dayOfWeek()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (t1 && t1 != tariff) {
|
||||
tariff = t1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
|
||||
parking_tariff_t *t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (t2 && t2->ValidFrom.isValid()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (start_.time() >= t2->ValidFrom) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (t2 && t2 != tariff) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
tariff = t2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = tariff;
|
||||
|
||||
qCritical() << __LINE__ << "compute_next_timestep() start: " << start_.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "compute_next_timestep() valid from: " << tariff->ValidFrom.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
|
||||
|
||||
@ -587,6 +983,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
qCritical() << __LINE__ << "compute_next_timestep() payment option index: " << paymentOptionIndex;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() plus steps: " << pop_plus_steps;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() minus steps: " << pop_minus_steps;
|
||||
qCritical() << __LINE__ << "compute_next_timestep() valid from: " << tariff->ValidFrom;
|
||||
|
||||
Configuration const *cfg = tariff;
|
||||
|
||||
@ -703,6 +1100,23 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
qCritical() << __LINE__ << "compute_next_timestep() next step index:" << nextStepIndex;
|
||||
if (nextStepIndex >= 0 && nextStepIndex < stepList.size()) {
|
||||
qCritical() << __LINE__ << "compute_next_timestep() return next time step:" << stepList[nextStepIndex];
|
||||
|
||||
// L264
|
||||
qCritical() << __LINE__ << "compute_next_timestep() TTTTTT tariff-files:" << tariff->tariffFileName;
|
||||
if (tariff->tariffFileName.contains("tariff02") ||
|
||||
tariff->tariffFileName.contains("tariff02_1700_2300") ||
|
||||
tariff->tariffFileName.contains("tariff02_1900_2300") ||
|
||||
tariff->tariffFileName.contains("tariff03") ||
|
||||
tariff->tariffFileName.contains("tariff03_H242_sat")) {
|
||||
QDateTime dt = start_.addSecs( stepList[nextStepIndex] * 60);
|
||||
qCritical() << __LINE__ << "compute_next_timestep() dt:" << dt.toString(Qt::ISODate);
|
||||
|
||||
if (dt.time() > QTime::fromString("23:11:59", Qt::ISODate)) {
|
||||
qCritical() << __LINE__ << "compute_next_timestep() dt:" << currentTimeMinutes;
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
}
|
||||
|
||||
return stepList[nextStepIndex];
|
||||
}
|
||||
}
|
||||
@ -771,15 +1185,32 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
start = start.toLocalTime().addSecs(start_parking_time * 60);
|
||||
QDateTime end(start);
|
||||
|
||||
start_ = start;
|
||||
|
||||
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||
// which means the code below will be executed only in such a case.
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
parking_tariff_t *t = tariffs[permitType].get();
|
||||
if (t && t != tariff) {
|
||||
tariff = t;
|
||||
parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (tariff != t1 && tariff != t2) {
|
||||
tariff = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = tariff;
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
|
||||
|
||||
} else
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
|
||||
}
|
||||
|
||||
int paymentOptionIndex = getPaymentOptionIndex(*tariff, start);
|
||||
if (paymentOptionIndex == -1) {
|
||||
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
|
||||
@ -851,6 +1282,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
PermitType permitType,
|
||||
bool prepaid)
|
||||
{
|
||||
start_ = start_parking_time_;
|
||||
|
||||
CalcState calcState;
|
||||
|
||||
QDateTime start_parking_time(start_parking_time_);
|
||||
@ -860,10 +1293,50 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
parking_tariff_t *t = tariffs[permitType].get();
|
||||
if (t && t != tariff) {
|
||||
tariff = t;
|
||||
parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (tariff != t1 && tariff != t2) {
|
||||
tariff = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
|
||||
parking_tariff_t *t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
if (t1 && t1->ValidFrom.isValid()) {
|
||||
if (start_parking_time_.time() >= t1->ValidFrom) {
|
||||
parking_tariff_t *t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (t2 && t2 != tariff) {
|
||||
if (t1 && t1 != tariff) {
|
||||
tariff = t1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (t1 && t1->ValidForWeekDay == start_.date().dayOfWeek()) {
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
if (t1 && t1 != tariff) {
|
||||
tariff = t1;
|
||||
qCritical() << __func__ << ":" << __LINE__;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
|
||||
parking_tariff_t *t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (t2 && t2 != tariff) {
|
||||
tariff = t2;
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = tariff;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||
<< isOutOfService(start_);
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
|
||||
|
||||
int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
|
||||
if (paymentOptionIndex == -1) {
|
||||
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
@ -886,24 +1359,32 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
<< " prepaid: " << prepaid
|
||||
<< " permitType: " << permitType.toString();
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
|
||||
|
||||
if (netto_parking_time < 0) {
|
||||
calcState.setDesc(QString("end=%1, start=%2")
|
||||
.arg(end_parking_time.toString(Qt::ISODate),
|
||||
start_parking_time.toString(Qt::ISODate)));
|
||||
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
|
||||
return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
|
||||
}
|
||||
if (netto_parking_time > maxMin) {
|
||||
calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin));
|
||||
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
|
||||
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
||||
}
|
||||
if (netto_parking_time < minMin) {
|
||||
calcState.setDesc(QString("duration=%1, minMin=%2").arg(netto_parking_time).arg(minMin));
|
||||
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
|
||||
return calcState.set(CalcState::State::BELOW_MIN_PARKING_TIME);
|
||||
}
|
||||
if (netto_parking_time == 0) {
|
||||
return calcState.set(CalcState::State::SUCCESS);
|
||||
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC" << netto_parking_time;
|
||||
// return calcState.set(CalcState::State::SUCCESS);
|
||||
}
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
|
||||
|
||||
double cost = -1;
|
||||
if (start_parking_time.isValid()) {
|
||||
if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps ||
|
||||
@ -1109,6 +1590,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
}
|
||||
} else
|
||||
if (tariff->getPaymentOptions(0).pop_payment_method_id == PaymentMethod::Unified) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
|
||||
std::pair<CalcState, std::optional<int>> p =
|
||||
Calculator::GetInstance().ComputeCostFromDuration(tariff, start_parking_time, end_parking_time, netto_parking_time);
|
||||
CalcState const cs = p.first;
|
||||
@ -1171,10 +1653,18 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
parking_tariff_t *t = tariffs[permitType].get();
|
||||
if (t && t != tariff) {
|
||||
tariff = t;
|
||||
parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (tariff != t1 && tariff != t2) {
|
||||
tariff = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = tariff;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||
<< isOutOfService(start_);
|
||||
|
||||
tariff->getPaymentOptions(0).pop_max_price
|
||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||
|
||||
@ -1183,6 +1673,9 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
QTime const t(0, 0, 0);
|
||||
QDateTime start(d, t, Qt::UTC);
|
||||
start = start.toLocalTime().addSecs(start_parking_time * 60);
|
||||
|
||||
start_ = start;
|
||||
|
||||
if (start.isValid()) {
|
||||
QString cs = start.toString(Qt::ISODate);
|
||||
|
||||
@ -1233,15 +1726,25 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
QDateTime &ticketEndTime,
|
||||
PermitType permitType)
|
||||
{
|
||||
start_ = start_parking_time;
|
||||
|
||||
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||
// which means the code below will be executed only in such a case.
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
parking_tariff_t *t = tariffs[permitType].get();
|
||||
if (t && t != tariff) {
|
||||
tariff = t;
|
||||
parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (tariff != t1 && tariff != t2) {
|
||||
tariff = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = tariff;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||
<< isOutOfService(start_);
|
||||
|
||||
tariff->getPaymentOptions(0).pop_max_price
|
||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||
|
||||
@ -1579,15 +2082,25 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff
|
||||
QDateTime &ticketEndTime,
|
||||
PermitType permitType)
|
||||
{
|
||||
start_ = start_parking_time;
|
||||
|
||||
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||
// which means the code below will be executed only in such a case.
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
parking_tariff_t *t = tariffs[permitType].get();
|
||||
if (t && t != tariff) {
|
||||
tariff = t;
|
||||
parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (tariff != t1 && tariff != t2) {
|
||||
tariff = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = tariff;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||
<< isOutOfService(start_);
|
||||
|
||||
tariff->getPaymentOptions(0).pop_max_price
|
||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||
|
||||
@ -1623,15 +2136,25 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_daily_ticket(
|
||||
PERMIT_TYPE permitType,
|
||||
struct price_t *price) {// return value
|
||||
|
||||
start_ = startDatetime;
|
||||
|
||||
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||
// which means the code below will be executed only in such a case.
|
||||
if (tariffs.count(permitType) > 0) {
|
||||
parking_tariff_t *t = tariffs[permitType].get();
|
||||
if (t && t != tariff) {
|
||||
tariff = t;
|
||||
parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
|
||||
parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
|
||||
if (tariff != t1 && tariff != t2) {
|
||||
tariff = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_tariff = tariff;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||
<< isOutOfService(start_);
|
||||
|
||||
tariff->getPaymentOptions(0).pop_max_price
|
||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||
|
||||
|
@ -749,6 +749,10 @@ Calculator::ComputeCostFromDuration(Configuration *cfg, QDateTime const &startDa
|
||||
CalcState returnState;
|
||||
|
||||
QList<int> keys = nettoParktimePrice.keys();
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "Times Keys" << keys;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "Prices Keys" << priceNettoParktime.keys();
|
||||
|
||||
int index = keys.indexOf(nettoParkingTime);
|
||||
if (index != -1) {
|
||||
int c = nettoParktimePrice[keys.at(index)];
|
||||
@ -3786,6 +3790,10 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: {
|
||||
}
|
||||
case PERMIT_TYPE::TEST_PRODUCT_1: {
|
||||
}
|
||||
case PERMIT_TYPE::TEST_PRODUCT_2: {
|
||||
}
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::DAY_TICKET: {
|
||||
} break;
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
#include <QPair>
|
||||
#include <QList>
|
||||
|
||||
/// <inheritdoc/>
|
||||
MemberType Configuration::IdentifyJsonMember(const char* member_name)
|
||||
@ -71,7 +73,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
|
||||
// start with new implementation of tariff-calculator
|
||||
// see for instance: bad neuenahr (249), Zone5
|
||||
|
||||
// qCritical() << __func__ << ":" << __LINE__ << innerObjName;
|
||||
qCritical() << __func__ << ":" << __LINE__ << innerObjName;
|
||||
|
||||
if (k->value.IsObject()) {
|
||||
auto obj = k->value.GetObject();
|
||||
@ -463,6 +465,14 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
|
||||
|
||||
}
|
||||
}
|
||||
ATBTariffSettings ts(max_price, min_price, max_time, min_time);
|
||||
ATBTariffCarryOverSettings cs(duration, start, end, parking_time_limit, about_to_exceed_limit,
|
||||
parkTimeLimitChecker);
|
||||
if (!d.isNull() && d.isValid()) { // special day, given in date-format
|
||||
WeekDay = ATBWeekDay(weekDay, weekDayName, ATBWeekDay::HOLIDAY, QDate(), ts, cs);
|
||||
} else {
|
||||
WeekDay = ATBWeekDay(weekDay, weekDayName, ATBWeekDay::USUAL_WEEKDAY, QDate(), ts, cs);
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (innerObjName == QString("week_day_default")) {
|
||||
@ -812,7 +822,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
ATBInterpolation TariffInterpolation;
|
||||
ATBPrepaid TariffPrepaidOption;
|
||||
ATBCarryOver TariffCarryOver;
|
||||
QStringList TariffIncludes;
|
||||
QList<QPair<QString, QString>> TariffIncludes;
|
||||
|
||||
MemberType mb_type = MemberType::UnknownType;
|
||||
this->currentPaymentOptions.clear();
|
||||
@ -878,32 +888,32 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
break;
|
||||
case MemberType::WeekDaysType: {
|
||||
ATBWeekDay WeekDay;
|
||||
if (QString(mb_name) == "Monday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Monday, mb_name);
|
||||
if (QString(mb_name).trimmed() == "Monday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Monday, QString(mb_name).trimmed());
|
||||
} else
|
||||
if (QString(mb_name) == "Tuesday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Tuesday, mb_name);
|
||||
if (QString(mb_name).trimmed() == "Tuesday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Tuesday, QString(mb_name).trimmed());
|
||||
} else
|
||||
if (QString(mb_name) == "Wednesday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Wednesday, mb_name);
|
||||
if (QString(mb_name).trimmed() == "Wednesday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Wednesday, QString(mb_name).trimmed());
|
||||
} else
|
||||
if (QString(mb_name) == "Thursday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Thursday, mb_name);
|
||||
if (QString(mb_name).trimmed() == "Thursday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Thursday, QString(mb_name).trimmed());
|
||||
} else
|
||||
if (QString(mb_name) == "Friday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Friday, mb_name);
|
||||
if (QString(mb_name).trimmed() == "Friday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Friday, QString(mb_name).trimmed());
|
||||
} else
|
||||
if (QString(mb_name) == "Saturday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Saturday, mb_name);
|
||||
if (QString(mb_name).trimmed() == "Saturday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Saturday, QString(mb_name).trimmed());
|
||||
} else
|
||||
if (QString(mb_name) == "Sunday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Sunday, mb_name);
|
||||
if (QString(mb_name).trimmed() == "Sunday") {
|
||||
WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Sunday, QString(mb_name).trimmed());
|
||||
} else {
|
||||
qCritical() << "ERROR: unknown week day" << mb_name;
|
||||
}
|
||||
|
||||
cfg->WeekDays.insert(pair<Qt::DayOfWeek, ATBWeekDay>(WeekDay.m_id, WeekDay));
|
||||
// qCritical() << WeekDay;
|
||||
qCritical() << __func__ << ":" << __LINE__ << cfg << "CCCC insert" << (int)WeekDay.m_id << WeekDay.m_name;
|
||||
|
||||
} break;
|
||||
case MemberType::CarryOverType: {
|
||||
@ -1345,7 +1355,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
else if (strcmp(inner_obj_name, "pcu_active") == 0) Currency.pcu_active = k->value.GetBool();
|
||||
break;
|
||||
case MemberType::IncludesType:
|
||||
TariffIncludes << k->value.GetString();
|
||||
TariffIncludes << QPair<QString, QString>(QString(inner_obj_name), k->value.GetString());
|
||||
break;
|
||||
case MemberType::PaymentMethodType:
|
||||
if (strcmp(inner_obj_name, "pme_id") == 0) PaymentMethod.pme_id = k->value.GetInt();
|
||||
|
Loading…
x
Reference in New Issue
Block a user