Compare commits

...

28 Commits

Author SHA1 Message Date
5749fa422e Added structures for parsing of tariff05 in bad neuenahr 2024-09-27 13:45:04 +02:00
1347f1f208 Added parsing for tariff05.json (bad neuenarh (249)) 2024-09-27 13:44:01 +02:00
576c3fefdd Added PaymentMethod::Unified 2024-09-27 13:42:44 +02:00
9ca7018fc1 tests for bad neuenahr 2024-09-27 13:42:04 +02:00
515dfaf35c reprogrammed to use ATBTime class 2024-09-27 13:41:30 +02:00
0ab833709c Added struct ATBTariffCarryOver 2024-09-27 13:40:18 +02:00
8e4f47c7b6 Added struct ATBTariffPrepaid 2024-09-27 13:39:35 +02:00
bc9645f1fa Minor: removed "pragma once" compiler flag 2024-09-27 13:38:39 +02:00
713b483918 Added/fixed several functions. final testing needed. 2024-09-27 13:37:54 +02:00
3c7af1cb32 Minor: Added tariff_service and tariff_out_of_service 2024-09-27 13:35:54 +02:00
356e451839 Add structures to encode service and out-of-service times 2024-09-27 13:35:03 +02:00
c4e1d412a5 Add some assinment operators to support assignment of tariff-time-ranges. 2024-09-27 13:31:01 +02:00
1b716c48d2 Fix: copy header files 2024-09-19 14:10:05 +02:00
77e1414c13 compute_duration_for_parking_ticket():
Recompute pop_max_price using netto-parking-time.
	Search Duration for the time-step with time-step == netto-parking-time,
	then search for the corresponding price in PaymentRate.
	The result is the new pop_max_price.
2024-09-17 17:05:23 +02:00
d95275a72d Compute real netto_parking_time.
This time will be used to find the real time-step, and from here the actual price to pay.
2024-09-17 17:04:27 +02:00
577a17dc6a Set seconds of serveral date-times to 0.
Compute netto_parking_time (which includes carry-over duration).
2024-09-17 17:03:29 +02:00
d8d32820a3 compute_price_for_parking_ticket():
Reset pop_max_price to original value using pop_max_price_saved.
2024-09-17 17:01:32 +02:00
2ce0aeef1d Minor: include atb_time.h 2024-09-17 16:59:07 +02:00
0cba85eafb Set pop_max_price_saved 2024-09-17 16:58:20 +02:00
4030a4b165 Add pop_max_price_save in case pop_max_price has to be re-computed dynamically, so it can be reset 2024-09-17 16:57:34 +02:00
8c7afdfcb1 Add additional constructor. 2024-09-17 16:53:45 +02:00
932d4e8cb9 check it ticket-end-time hits carry-over-start. if configured, move to end of carry-over. 2024-09-16 16:56:48 +02:00
38abc65425 compute_price_for_parking_ticket():
Check if minutesUntilCarryOver is positive (usually must be).
2024-09-16 16:54:25 +02:00
205896903b Handle SUCCESS_MAXPRICE (calc-state). 2024-09-16 16:53:44 +02:00
dbedfd094f Add some OTHER files 2024-09-16 16:52:00 +02:00
57b9d16abc GetDurationFromCost():
Handle carry-over for direct coin insertion.
	Carefully check if this might be a problem for other projects.
2024-09-16 16:50:16 +02:00
48afbc071c Added new calc-state: SUCCESS_MAXPRICE.
Return whenever cost (=price) equals max-price.
2024-09-16 16:49:00 +02:00
7a7b10260a Add untracked(!) files 2024-09-16 16:47:01 +02:00
19 changed files with 1067 additions and 47 deletions

View File

@@ -4,19 +4,42 @@
#include <QDateTime> #include <QDateTime>
class ATBTime { class ATBTime {
QDateTime const m_end; static QDateTime const m_end;
mutable QDateTime m_time; mutable QDateTime m_time;
public: public:
explicit ATBTime(); explicit ATBTime();
explicit ATBTime(int h, int m, int s = 0, int ms = 0); explicit ATBTime(int h, int m, int s = 0, int ms = 0);
explicit ATBTime(QString const &time);
explicit ATBTime(QTime const &time);
explicit ATBTime(ATBTime const &atbTime) {
m_time = atbTime.m_time;
}
ATBTime &operator=(ATBTime && atbTime) {
m_time = std::move(atbTime.m_time);
return *this;
}
ATBTime &operator=(ATBTime const &atbTime) {
m_time = atbTime.m_time;
return *this;
}
int hour() const { return m_time.time().hour(); } int hour() const { return m_time.time().hour(); }
int minute() const { return m_time.time().minute(); } int minute() const { return m_time.time().minute(); }
int second() const { return m_time.time().second(); } int second() const { return m_time.time().second(); }
int msec() const { return m_time.time().msec(); } int msec() const { return m_time.time().msec(); }
int secsTo(QTime t) const { return m_time.time().secsTo(t); } int secsTo(QString const &t) const {
if (t == "24:00:00") {
return m_time.secsTo(m_end);
}
return m_time.time().secsTo(QTime::fromString(t, Qt::ISODate));
}
int msecsTo(QTime t) const { return m_time.time().msecsTo(t); } int msecsTo(QTime t) const { return m_time.time().msecsTo(t); }
bool setHMS(int h, int m, int s, int ms = 0); bool setHMS(int h, int m, int s, int ms = 0);
@@ -47,10 +70,12 @@ public:
friend bool operator!=(const ATBTime &lhs, const ATBTime &rhs) noexcept; friend bool operator!=(const ATBTime &lhs, const ATBTime &rhs) noexcept;
friend bool operator<(const ATBTime &lhs, const ATBTime &rhs) noexcept; friend bool operator<(const ATBTime &lhs, const ATBTime &rhs) noexcept;
friend bool operator<=(const ATBTime &lhs, const ATBTime &rhs) noexcept; friend bool operator<=(const ATBTime &lhs, const ATBTime &rhs) noexcept;
friend bool operator>=(const ATBTime &lhs, const ATBTime &rhs) noexcept;
friend bool operator<(const ATBTime &lhs, const ATBTime &rhs) noexcept; friend bool operator<(const ATBTime &lhs, const ATBTime &rhs) noexcept;
friend bool operator>(const ATBTime &lhs, const ATBTime &rhs) noexcept; friend bool operator>(const ATBTime &lhs, const ATBTime &rhs) noexcept;
friend bool operator==(const ATBTime &lhs, const ATBTime &rhs) noexcept; friend bool operator==(const ATBTime &lhs, const ATBTime &rhs) noexcept;
friend QDataStream &operator<<(QDataStream &out, ATBTime time); friend QDataStream &operator<<(QDataStream &out, ATBTime const &time);
friend QDebug &operator<<(QDebug &out, ATBTime const &time);
friend QDataStream &operator>>(QDataStream &in, ATBTime &time); friend QDataStream &operator>>(QDataStream &in, ATBTime &time);
}; };

View File

@@ -56,6 +56,7 @@ struct CALCULATE_LIBRARY_API CalcState {
static QString const ABOVE_MAX_PARKING_PRICE; static QString const ABOVE_MAX_PARKING_PRICE;
static QString const OVERPAID; static QString const OVERPAID;
static QString const OUTSIDE_ALLOWED_PARKING_TIME; static QString const OUTSIDE_ALLOWED_PARKING_TIME;
static QString const SUCCESS_MAXPRICE;
enum class State : uint8_t { enum class State : uint8_t {
SUCCESS, SUCCESS,
@@ -71,7 +72,8 @@ struct CALCULATE_LIBRARY_API CalcState {
BELOW_MIN_PARKING_PRICE, BELOW_MIN_PARKING_PRICE,
ABOVE_MAX_PARKING_PRICE, ABOVE_MAX_PARKING_PRICE,
OVERPAID, OVERPAID,
OUTSIDE_ALLOWED_PARKING_TIME OUTSIDE_ALLOWED_PARKING_TIME,
SUCCESS_MAXPRICE
}; };
State m_status; State m_status;
@@ -106,6 +108,9 @@ struct CALCULATE_LIBRARY_API CalcState {
case State::SUCCESS: case State::SUCCESS:
s = CalcState::SUCCESS; s = CalcState::SUCCESS;
break; break;
case State::SUCCESS_MAXPRICE:
s = CalcState::SUCCESS_MAXPRICE;
break;
case State::ERROR_PARSING_ZONE_NR: case State::ERROR_PARSING_ZONE_NR:
s = CalcState::ERROR_PARSING_ZONE_NR; s = CalcState::ERROR_PARSING_ZONE_NR;
break; break;
@@ -158,6 +163,9 @@ struct CALCULATE_LIBRARY_API CalcState {
case State::SUCCESS: case State::SUCCESS:
s = CalcState::SUCCESS; s = CalcState::SUCCESS;
break; break;
case State::SUCCESS_MAXPRICE:
s = CalcState::SUCCESS_MAXPRICE;
break;
case State::ERROR_PARSING_ZONE_NR: case State::ERROR_PARSING_ZONE_NR:
s = CalcState::ERROR_PARSING_ZONE_NR; s = CalcState::ERROR_PARSING_ZONE_NR;
break; break;
@@ -207,6 +215,9 @@ struct CALCULATE_LIBRARY_API CalcState {
if (desc == SUCCESS) { if (desc == SUCCESS) {
m_status = State::SUCCESS; m_status = State::SUCCESS;
} else } else
if (desc == SUCCESS_MAXPRICE) {
m_status = State::SUCCESS_MAXPRICE;
}
if (desc == ERROR_PARSING_ZONE_NR) { if (desc == ERROR_PARSING_ZONE_NR) {
m_status = State::ERROR_PARSING_ZONE_NR; m_status = State::ERROR_PARSING_ZONE_NR;
} else } else

View File

@@ -29,6 +29,8 @@
#include "tariff_prepaid.h" #include "tariff_prepaid.h"
#include "tariff_carryover.h" #include "tariff_carryover.h"
#include "tariff_permit_type.h" #include "tariff_permit_type.h"
#include "tariff_service.h"
#include "tariff_out_of_service.h"
#include <QVector> #include <QVector>
#include <optional> #include <optional>
@@ -50,6 +52,10 @@ public:
using TariffPrepaidType = std::multimap<int, ATBPrepaid>; using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
using TariffCarryOverType = std::multimap<int, ATBCarryOver>; using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
using TariffDurationType = std::multimap<int, ATBDuration>; using TariffDurationType = std::multimap<int, ATBDuration>;
using TariffServiceType = std::multimap<int, ATBTariffService>;
using TariffOutOfServiceType = std::multimap<int, ATBTariffOutOfService>;
using ATBTariffPrepaidType = std::multimap<int, ATBTariffPrepaid>;
using ATBTariffCarryOverType = std::multimap<int, ATBTariffCarryOver>;
ATBProject project; ATBProject project;
ATBCurrency Currency; ATBCurrency Currency;
@@ -73,6 +79,10 @@ public:
TariffInterpolationType TariffInterpolations; TariffInterpolationType TariffInterpolations;
TariffPrepaidType TariffPrepaidOptions; TariffPrepaidType TariffPrepaidOptions;
TariffCarryOverType TariffCarryOverOptions; TariffCarryOverType TariffCarryOverOptions;
TariffServiceType TariffServices;
TariffOutOfServiceType TariffOutOfServices;
ATBTariffPrepaidType TariffPrepaids;
ATBTariffCarryOverType TariffCarryOvers;
/// <summary> /// <summary>
/// Parse JSON string /// Parse JSON string

View File

@@ -25,6 +25,7 @@ public:
pop_max_time = 0; pop_max_time = 0;
pop_min_price = 0; pop_min_price = 0;
pop_max_price = 0; pop_max_price = 0;
pop_max_price_save = 0;
pop_carry_over = -1; pop_carry_over = -1;
pop_carry_over_option_id = -1; pop_carry_over_option_id = -1;
pop_prepaid_option_id = -1; pop_prepaid_option_id = -1;
@@ -61,6 +62,7 @@ public:
double pop_max_time; double pop_max_time;
double pop_min_price; double pop_min_price;
double pop_max_price; double pop_max_price;
double pop_max_price_save;
int pop_carry_over; int pop_carry_over;
int pop_carry_over_option_id; int pop_carry_over_option_id;
bool pop_truncate_last_interpolation_step; bool pop_truncate_last_interpolation_step;

View File

@@ -3,6 +3,80 @@
#include <QTime> #include <QTime>
#include "time_range.h"
enum class ApplyCarryOver {
NEVER = 0,
MATCH_PREV_DAY = 1,
MATCH_NEXT_DAY = 2,
ALWAYS = 3
};
struct ATBTariffCarryOver {
int m_id;
QString m_weekDay;
TimeRange m_range;
QDate m_date;
ApplyCarryOver m_carryOverIf;
explicit ATBTariffCarryOver()
: m_id(-1)
, m_carryOverIf(ApplyCarryOver::NEVER) {
}
void setCarryOverIf(QString const &coif) {
if (coif == "never") {
m_carryOverIf = ApplyCarryOver::NEVER;
} else
if (coif == "match_prev_day") {
m_carryOverIf = ApplyCarryOver::MATCH_PREV_DAY;
} else
if (coif == "match_next_day") {
m_carryOverIf = ApplyCarryOver::MATCH_NEXT_DAY;
} else
if (coif == "always") {
m_carryOverIf = ApplyCarryOver::ALWAYS;
} else {
qCritical() << "ERROR unknown carry over application" << coif;
}
}
ApplyCarryOver carryOverIf() const {
return m_carryOverIf;
}
QString carryOverIfStr() const {
if (m_carryOverIf == ApplyCarryOver::NEVER) {
return "never";
}
if (m_carryOverIf == ApplyCarryOver::ALWAYS) {
return "always";
}
if (m_carryOverIf == ApplyCarryOver::MATCH_PREV_DAY) {
return "match prev day";
}
if (m_carryOverIf == ApplyCarryOver::MATCH_NEXT_DAY) {
return "match next day";
}
return QString("ERROR unknown carry over application: %1").arg(static_cast<int>(m_carryOverIf));
}
friend QDebug operator<<(QDebug debug, ATBTariffCarryOver const &co) {
QDebugStateSaver saver(debug);
debug.nospace()
<< "\nTariffCarryOver:\n"
<< " week day: " << co.m_weekDay << "\n"
<< " date: " << co.m_date.toString(Qt::ISODate) << "\n"
<< " id: " << co.m_id << "\n"
<< " start: " << co.m_range.m_start << "\n"
<< " end: " << co.m_range.m_end << "\n"
<< " duration: " << co.m_range.m_duration << "\n"
<< " carry over if: " << co.carryOverIfStr() << endl;
return debug;
}
};
struct ATBCarryOver { struct ATBCarryOver {
struct week { struct week {
int day; int day;

View File

@@ -1,4 +1,3 @@
#pragma once
#include <variant> #include <variant>
#include <cstddef> #include <cstddef>
#include <stdio.h> #include <stdio.h>

View File

@@ -0,0 +1,79 @@
#ifndef TARIFF_OUT_OF_SERVICE_H_INCLUDED
#define TARIFF_OUT_OF_SERVICE_H_INCLUDED
#include <QDateTime>
#include <QString>
#include "time_range.h"
enum class ApplyOutOfService {
NEVER = 0,
MATCH_PREV_DAY = 1,
MATCH_NEXT_DAY = 2,
ALWAYS = 3
};
struct ATBTariffOutOfService {
int m_id;
QString m_weekDay;
QDate m_date;
TimeRange m_range;
ApplyOutOfService m_outOfServiceIf;
explicit ATBTariffOutOfService()
: m_id(-1)
, m_outOfServiceIf(ApplyOutOfService::NEVER) {
}
void setOutOfServiceIf(QString const &oosif) {
if (oosif == "never") {
m_outOfServiceIf = ApplyOutOfService::NEVER;
} else
if (oosif == "match_prev_day") {
m_outOfServiceIf = ApplyOutOfService::MATCH_PREV_DAY;
} else
if (oosif == "match_next_day") {
m_outOfServiceIf = ApplyOutOfService::MATCH_NEXT_DAY;
} else
if (oosif == "always") {
m_outOfServiceIf = ApplyOutOfService::ALWAYS;
} else {
qCritical() << "ERROR unknown servcie application" << oosif;
}
}
ApplyOutOfService outOfServiceIf() const {
return m_outOfServiceIf;
}
QString outOfServiceIfStr() const {
if (m_outOfServiceIf == ApplyOutOfService::NEVER) {
return "never";
}
if (m_outOfServiceIf == ApplyOutOfService::ALWAYS) {
return "always";
}
if (m_outOfServiceIf == ApplyOutOfService::MATCH_PREV_DAY) {
return "match prev day";
}
if (m_outOfServiceIf == ApplyOutOfService::MATCH_NEXT_DAY) {
return "match next day";
}
return QString("ERROR unknown out of service application: %1").arg(static_cast<int>(m_outOfServiceIf));
}
friend QDebug operator<<(QDebug debug, ATBTariffOutOfService const &oos) {
QDebugStateSaver saver(debug);
debug.nospace()
<< "\nTariffOutOfService:\n"
<< " week day: " << oos.m_weekDay << "\n"
<< " date: " << oos.m_date.toString(Qt::ISODate) << "\n"
<< " id: " << oos.m_id << "\n"
<< " start: " << oos.m_range.m_start << "\n"
<< " end: " << oos.m_range.m_end << "\n"
<< " duration: " << oos.m_range.m_duration << endl;
return debug;
}
};
#endif // TARIFF_SERVICE_H_INCLUDED

View File

@@ -1,9 +1,85 @@
#ifndef TARIFF_PREPAID_H_INCLUDED #ifndef TARIFF_PREPAID_H_INCLUDED
#define TARIFF_PREPAID_H_INCLUDED #define TARIFF_PREPAID_H_INCLUDED
#include <QTime> #include <QDateTime>
#include <QString> #include <QString>
#include "time_range.h"
enum class ApplyPrepaid {
NEVER = 0,
MATCH_PREV_DAY = 1,
MATCH_NEXT_DAY = 2,
ALWAYS = 3
};
struct ATBTariffPrepaid {
int m_id;
QString m_weekDay;
QDate m_date;
TimeRange m_range;
ApplyPrepaid m_prepaidIf;
explicit ATBTariffPrepaid()
: m_id(-1)
, m_prepaidIf(ApplyPrepaid::NEVER) {
}
void setPrepaidIf(QString const &ppif) {
if (ppif == "never") {
m_prepaidIf = ApplyPrepaid::NEVER;
} else
if (ppif == "match_prev_day") {
m_prepaidIf = ApplyPrepaid::MATCH_PREV_DAY;
} else
if (ppif == "match_next_day") {
m_prepaidIf = ApplyPrepaid::MATCH_NEXT_DAY;
} else
if (ppif == "always") {
m_prepaidIf = ApplyPrepaid::ALWAYS;
} else {
qCritical() << "ERROR unknown carry over application" << ppif;
}
}
ApplyPrepaid prepaidIf() const {
return m_prepaidIf;
}
QString prepaidIfStr() const {
if (m_prepaidIf == ApplyPrepaid::NEVER) {
return "never";
}
if (m_prepaidIf == ApplyPrepaid::ALWAYS) {
return "always";
}
if (m_prepaidIf == ApplyPrepaid::MATCH_PREV_DAY) {
return "match prev day";
}
if (m_prepaidIf == ApplyPrepaid::MATCH_NEXT_DAY) {
return "match next day";
}
return QString("ERROR unknown prepaid application: %1").arg(static_cast<int>(m_prepaidIf));
}
friend QDebug operator<<(QDebug debug, ATBTariffPrepaid const &pp) {
QDebugStateSaver saver(debug);
debug.nospace()
<< "\nTariffPrepaid:\n"
<< " week day: " << pp.m_weekDay << "\n"
<< " date: " << pp.m_date.toString(Qt::ISODate) << "\n"
<< " id: " << pp.m_id << "\n"
<< " start: " << pp.m_range.m_start << "\n"
<< " end: " << pp.m_range.m_end << "\n"
<< " duration: " << pp.m_range.m_duration << "\n"
<< " prepaid if: " << pp.prepaidIfStr() << endl;
return debug;
}
};
// deprecated
struct ATBPrepaid { struct ATBPrepaid {
int id; int id;
bool anytime; bool anytime;

View File

@@ -0,0 +1,81 @@
#ifndef TARIFF_SERVICE_H_INCLUDED
#define TARIFF_SERVICE_H_INCLUDED
#include <QDateTime>
#include <QString>
#include "time_range.h"
enum class ApplyService {
NEVER = 0,
MATCH_PREV_DAY = 1,
MATCH_NEXT_DAY = 2,
ALWAYS = 3
};
struct ATBTariffService {
int m_id;
QString m_weekDay;
QDate m_date;
TimeRange m_range;
ApplyService m_serviceIf;
explicit ATBTariffService()
: m_id(-1)
, m_serviceIf(ApplyService::NEVER) {
}
void setServiceIf(QString const &sif) {
if (sif == "never") {
m_serviceIf = ApplyService::NEVER;
} else
if (sif == "match_prev_day") {
m_serviceIf = ApplyService::MATCH_PREV_DAY;
} else
if (sif == "match_next_day") {
m_serviceIf = ApplyService::MATCH_NEXT_DAY;
} else
if (sif == "always") {
m_serviceIf = ApplyService::ALWAYS;
} else {
qCritical() << "ERROR unknown servcie application" << sif;
}
}
ApplyService serviceIf() const {
return m_serviceIf;
}
QString serviceIfStr() const {
if (m_serviceIf == ApplyService::NEVER) {
return "never";
}
if (m_serviceIf == ApplyService::ALWAYS) {
return "always";
}
if (m_serviceIf == ApplyService::MATCH_PREV_DAY) {
return "match prev day";
}
if (m_serviceIf == ApplyService::MATCH_NEXT_DAY) {
return "match next day";
}
return QString("ERROR unknown service application: %1").arg(static_cast<int>(m_serviceIf));
}
friend QDebug operator<<(QDebug debug, ATBTariffService const &ts) {
QDebugStateSaver saver(debug);
debug.nospace()
<< "\nTariffService:\n"
<< " week day: " << ts.m_weekDay << "\n"
<< " date: " << ts.m_date.toString(Qt::ISODate) << "\n"
<< " id: " << ts.m_id << "\n"
<< " start: " << ts.m_range.m_start << "\n"
<< " end: " << ts.m_range.m_end << "\n"
<< " duration: " << ts.m_range.m_duration << "\n"
<< " prepaid if: " << ts.serviceIfStr() << endl;
return debug;
}
};
#endif // TARIFF_SERVICE_H_INCLUDED

View File

@@ -1,12 +1,39 @@
#ifndef TIME_RANGE_H_INCLUDED #ifndef TIME_RANGE_H_INCLUDED
#define TIME_RANGE_H_INCLUDED #define TIME_RANGE_H_INCLUDED
#include "time_range_header.h" #include "atb_time.h"
#include <QString>
struct TimeRange { struct TimeRange {
public: ATBTime m_start;
bool IsActive; ATBTime m_end;
ATBTimeRange TimeRangeStructure; int m_duration;
explicit TimeRange() = default;
explicit TimeRange(QString const &start, QString const &end, int duration)
: m_start(start)
, m_end(end)
, m_duration(duration) {
}
explicit TimeRange(ATBTime const &start, ATBTime const &end, int duration)
: m_start(start)
, m_end(end)
, m_duration(duration) {
}
explicit TimeRange(TimeRange const &timeRange) {
m_start = timeRange.m_start;
m_end = timeRange.m_end;
m_duration = timeRange.m_duration;
}
TimeRange &operator=(TimeRange && timeRange) {
m_start = std::move(timeRange.m_start);
m_end = std::move(timeRange.m_end);
m_duration = timeRange.m_duration;
return *this;
}
}; };
#endif // TIME_RANGE_H_INCLUDED #endif // TIME_RANGE_H_INCLUDED

View File

@@ -91,7 +91,9 @@ HEADERS += \
include/mobilisis/tariff_prepaid.h \ include/mobilisis/tariff_prepaid.h \
include/mobilisis/tariff_carryover.h \ include/mobilisis/tariff_carryover.h \
include/mobilisis/tariff_global_defines.h \ include/mobilisis/tariff_global_defines.h \
include/mobilisis/atb_time.h include/mobilisis/atb_time.h \
include/mobilisis/tariff_service.h \
include/mobilisis/tariff_out_of_service.h
OTHER_FILES += src/main.cpp \ OTHER_FILES += src/main.cpp \
../tariffs/tariff_korneuburg.json \ ../tariffs/tariff_korneuburg.json \

View File

@@ -1,16 +1,38 @@
#include "atb_time.h" #include "atb_time.h"
#include <QDebugStateSaver>
QDateTime const ATBTime::m_end(QDateTime::fromString("1970-01-02T00:00:00", Qt::ISODate));
ATBTime::ATBTime() ATBTime::ATBTime()
: m_end(QDateTime::fromString("1970-01-02T00:00:00")) : m_time(QDateTime::fromString("1970-01-01T00:00:00", Qt::ISODate)) {
, m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
} }
ATBTime::ATBTime(int h, int m, int s, int ms) ATBTime::ATBTime(int h, int m, int /*s*/, int /*ms*/)
: m_end(QDateTime::fromString("1970-01-02T00:00:00")) : m_time(QDateTime::fromString("1970-01-01T00:00:00", Qt::ISODate)) {
, m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
QTime t(h, m, s, ms); if (h == 24 && m == 0) {
m_time = m_end;
} else {
QTime const t(h, m, 0, 0);
m_time.setTime(t);
}
}
ATBTime::ATBTime(QString const &t)
: m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
if (t == "24:00:00") {
m_time = m_end;
} else {
QTime tmp = QTime::fromString(t, Qt::ISODate);
if (tmp.isValid()) {
m_time.setTime(tmp);
}
}
}
ATBTime::ATBTime(QTime const &t)
: m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
m_time.setTime(t); m_time.setTime(t);
} }
@@ -66,6 +88,9 @@ bool ATBTime::setHMS(int h, int m, int s, int ms) {
} }
QString ATBTime::toString(Qt::DateFormat format) const { QString ATBTime::toString(Qt::DateFormat format) const {
if (m_time == m_end) {
return "24:00:00";
}
return m_time.time().toString(format); return m_time.time().toString(format);
} }
@@ -74,11 +99,20 @@ bool operator!=(const ATBTime &lhs, const ATBTime &rhs) noexcept {
} }
bool operator<=(const ATBTime &lhs, const ATBTime &rhs) noexcept { bool operator<=(const ATBTime &lhs, const ATBTime &rhs) noexcept {
if (rhs.m_time == rhs.m_end) {
return true;
}
return lhs.m_time.time() <= rhs.m_time.time(); return lhs.m_time.time() <= rhs.m_time.time();
}
bool operator>=(const ATBTime &lhs, const ATBTime &rhs) noexcept {
return lhs.m_time.time() >= rhs.m_time.time();
} }
bool operator<(const ATBTime &lhs, const ATBTime &rhs) noexcept { bool operator<(const ATBTime &lhs, const ATBTime &rhs) noexcept {
if (rhs.m_time == rhs.m_end) {
return true;
}
return lhs.m_time.time() < rhs.m_time.time(); return lhs.m_time.time() < rhs.m_time.time();
} }
@@ -90,8 +124,22 @@ bool operator==(const ATBTime &lhs, const ATBTime &rhs) noexcept {
return lhs.m_time.time() == rhs.m_time.time(); return lhs.m_time.time() == rhs.m_time.time();
} }
QDataStream &operator<<(QDataStream &out, ATBTime time) { QDebug &operator<<(QDebug &debug, ATBTime const &time) {
QDebugStateSaver saver(debug);
if (time.m_time == time.m_end) {
debug.nospace() << QString("24:00:00");
} else {
debug.nospace() << time.m_time.time().toString(Qt::ISODate);
}
return debug;
}
QDataStream &operator<<(QDataStream &out, ATBTime const &time) {
if (time.m_time == time.m_end) {
out << QString("24:00:00");
} else {
out << time.m_time.time(); out << time.m_time.time();
}
return out; return out;
} }

View File

@@ -26,6 +26,7 @@ QString const CalcState::BELOW_MIN_PARKING_PRICE = "BELOW_MIN_PARKING_PRICE";
QString const CalcState::ABOVE_MAX_PARKING_PRICE = "ABOVE_MAX_PARKING_PRICE"; QString const CalcState::ABOVE_MAX_PARKING_PRICE = "ABOVE_MAX_PARKING_PRICE";
QString const CalcState::OVERPAID = "OVERPAID"; QString const CalcState::OVERPAID = "OVERPAID";
QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME"; QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME";
QString const CalcState::SUCCESS_MAXPRICE = "SUCCESS_MAXPRICE";
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) { QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
return Calculator::GetInstance().GetTimeSteps(cfg); return Calculator::GetInstance().GetTimeSteps(cfg);
@@ -76,6 +77,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
if (paymentOptionIndex == -1) { if (paymentOptionIndex == -1) {
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType); paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
} }
int maxTime = 0; int maxTime = 0;
switch(permitType) { switch(permitType) {
@@ -682,6 +684,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get()); paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
} }
tariff->getPaymentOptions(paymentOptionIndex).pop_max_price
= tariff->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_min_time; double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_min_time;
double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_max_time; double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_max_time;
@@ -752,6 +757,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType); paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
} }
tariff->getPaymentOptions(paymentOptionIndex).pop_max_price
= tariff->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time; double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time; double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
@@ -818,6 +826,13 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
qCritical() << __func__ << ":" << __LINE__ << " re-computed prepaid-id" << pop_prepaid_option_id; qCritical() << __func__ << ":" << __LINE__ << " re-computed prepaid-id" << pop_prepaid_option_id;
} }
QTime carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
int carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration" << carryOverDuration;
QDateTime effectiveStartTime(start_parking_time); QDateTime effectiveStartTime(start_parking_time);
// handle special days // handle special days
@@ -870,6 +885,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
} }
} }
effectiveStartTime.setTime(QTime(effectiveStartTime.time().hour(),
effectiveStartTime.time().minute(), 0));
qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:" << effectiveStartTime.toString(Qt::ISODate); qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:" << effectiveStartTime.toString(Qt::ISODate);
int const carryOver = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over; int const carryOver = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over;
@@ -885,7 +903,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
// handle carry over // handle carry over
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60; int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
if (netto_parking_time > minutesUntilCarryOver) { if ((minutesUntilCarryOver > 0) && (netto_parking_time > minutesUntilCarryOver)) {
int const rest = netto_parking_time - minutesUntilCarryOver; int const rest = netto_parking_time - minutesUntilCarryOver;
QDateTime s(effectiveStartTime); QDateTime s(effectiveStartTime);
s = s.addSecs(minutesUntilCarryOver * 60); s = s.addSecs(minutesUntilCarryOver * 60);
@@ -935,6 +953,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
//QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit(); //QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit();
//end_parking_time.setTime(tlimit); //end_parking_time.setTime(tlimit);
// max_price neu berechnen
calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__) calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
.arg(end_parking_time.time().toString(Qt::ISODate))); .arg(end_parking_time.time().toString(Qt::ISODate)));
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME); return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
@@ -1071,6 +1091,10 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::STATIC) { if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::STATIC) {
// handle prepaid option // handle prepaid option
QDateTime effectiveStartTime(start_parking_time); QDateTime effectiveStartTime(start_parking_time);
effectiveStartTime.setTime(QTime(effectiveStartTime.time().hour(),
effectiveStartTime.time().minute(), 0));
int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id; int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id); std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
if (prepaidOption.has_value()) { if (prepaidOption.has_value()) {
@@ -1087,8 +1111,9 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
} }
} }
} }
QDateTime start(start_parking_time);
QString cs = start_parking_time.toString(Qt::ISODate); start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
QString cs = start.toString(Qt::ISODate);
std::pair<std::string, QDateTime> p_endTime std::pair<std::string, QDateTime> p_endTime
= Calculator::GetInstance().GetDurationFromCost( = Calculator::GetInstance().GetDurationFromCost(
@@ -1103,6 +1128,12 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
if (endTime == CalcState::SUCCESS) { if (endTime == CalcState::SUCCESS) {
calcState.setDesc(QString("SUCCESS")); calcState.setDesc(QString("SUCCESS"));
calcState.setStatus(endTime); calcState.setStatus(endTime);
qCritical() << __func__ << ":" << __LINE__ << "SUCCESS";
} else
if (endTime == CalcState::SUCCESS_MAXPRICE) {
calcState.setDesc(QString("SUCCESS_MAXPRICE"));
calcState.setStatus(endTime);
qCritical() << __func__ << ":" << __LINE__ << "SUCCESS_MAXPRICE";
} else } else
if (endTime == CalcState::ERROR_PARSING_ZONE_NR) { if (endTime == CalcState::ERROR_PARSING_ZONE_NR) {
calcState.setStatus(endTime); calcState.setStatus(endTime);
@@ -1160,8 +1191,14 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
} else { } else {
ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate); ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
ticketEndTime.setTime(QTime(ticketEndTime.time().hour(),
ticketEndTime.time().minute(), 0));
int netto_parking_time = start_parking_time.secsTo(ticketEndTime) / 60;
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate); qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
qCritical() << __func__ << ":" << __LINE__ << "step-config:" << pop_time_step_config; qCritical() << __func__ << ":" << __LINE__ << "step-config:" << pop_time_step_config;
qCritical() << __func__ << ":" << __LINE__ << "netto-parking-time" << netto_parking_time;
if (!ticketEndTime.isValid()) { if (!ticketEndTime.isValid()) {
calcState.setDesc(QString("ticketEndTime=%1").arg(endTime)); calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
@@ -1203,10 +1240,25 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
} }
if (carryOverStart.isValid() && carryOverEnd.isValid() && carryOverDuration != -1) { if (carryOverStart.isValid() && carryOverEnd.isValid() && carryOverDuration != -1) {
// note: in such a case (direct coins) carry-over has been handled
// already in GetDurationFromCost()
netto_parking_time -= carryOverDuration;
qCritical() << __func__ << ":" << __LINE__ << "netto-parking-time" << netto_parking_time;
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate); // qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
if (ticketEndTime.time() > carryOverStart) { if (ticketEndTime.time() > carryOverStart) {
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate); // qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60); ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
} else
if (ticketEndTime.time() == carryOverStart) {
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
if (po.pop_apply_carry_over_to_ticket_endtime) {
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
}
} else { } else {
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate); // qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
if (ticketEndTime.time() < carryOverEnd) { if (ticketEndTime.time() < carryOverEnd) {
@@ -1219,23 +1271,85 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
} }
} }
ticketEndTime.setTime(QTime(ticketEndTime.time().hour(),
ticketEndTime.time().minute(), 0));
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate); qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
for (auto[itr, rangeEnd] = tariff->WeekDays.equal_range((Qt::DayOfWeek)(ticketEndTime.date().dayOfWeek())); for (auto[itr, rangeEnd] = tariff->WeekDays.equal_range((Qt::DayOfWeek)(ticketEndTime.date().dayOfWeek()));
itr != rangeEnd; itr != rangeEnd;
++itr) { ++itr) {
ATBWeekDay const &wd = itr->second; ATBWeekDay const &wd = itr->second;
bool const parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(start_parking_time, bool parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(start_parking_time,
ticketEndTime, ticketEndTime,
paymentOptionIndex); paymentOptionIndex);
if (parkTimeLimitViolated) { if (parkTimeLimitViolated) {
//QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit(); //QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit();
//ticketEndTime.setTime(tlimit); //ticketEndTime.setTime(tlimit);
QList<int> const &stepList = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
QDateTime newTicketEndTime = ticketEndTime;
qCritical() << __func__ << ":" << __LINE__ << "PARK-TIME VIOLATED";
for (int i = stepList.size() - 1; i > 0; --i) {
// qCritical() << __func__ << ":" << __LINE__ << "step[" << i << "]" << stepList.at(i);
if (netto_parking_time > 0 && stepList.at(i) <= netto_parking_time) {
int const diff = stepList.at(i-1) - stepList.at(i);
newTicketEndTime = newTicketEndTime.addSecs(diff * 60);
// qCritical() << __func__ << ":" << __LINE__ << "new-ticket-end-time" << newTicketEndTime.toString(Qt::ISODate);
parkTimeLimitViolated
= wd.getTariffCarryOverSettings()
.parkingTimeLimitExceeded(start_parking_time, newTicketEndTime, paymentOptionIndex);
if (!parkTimeLimitViolated) {
qCritical() << __func__ << ":" << __LINE__
<< "PARK-TIME NOT VIOLATED FOR" << newTicketEndTime.toString(Qt::ISODate);
int duration = stepList.at(i-1);
// qCritical() << __func__ << ":" << __LINE__ << "duration" << duration;
std::multimap<int, ATBDuration>::const_iterator it;
for (it = tariff->Duration.cbegin();
it != tariff->Duration.cend();
++it) {
if (duration == it->second.pun_duration) {
// qCritical() << __func__ << ":" << __LINE__ << "duration" << duration;
ATBPaymentOption &po = tariff->getPaymentOptions(paymentOptionIndex);
int const pop_id = po.pop_id;
for (auto[itr, rangeEnd] = tariff->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const durationId = itr->second.pra_payment_unit_id;
// qCritical() << __func__ << ":" << __LINE__ << "durationId" << durationId << it->second.pun_id;
// note: for this to work, Duration and PaymentRate must have
// exactly the same structure
if (durationId == it->second.pun_id) {
int const pra_price = itr->second.pra_price;
po.pop_max_price = pra_price;
qCritical() << __func__ << ":" << __LINE__ << "new max-price" << po.pop_max_price;
// note: ABOVE_MAX_PARKING_TIME would also be possible
// but here max-parking-time is dynamic. And for
// this dynamic value, opverpaid is actually correct
calcState.setDesc(CalcState::OVERPAID);
calcState.setStatus(CalcState::OVERPAID);
return calcState;
}
}
}
}
}
}
}
calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__) calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
.arg(ticketEndTime.time().toString(Qt::ISODate))); .arg(ticketEndTime.time().toString(Qt::ISODate)));
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME); return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
@@ -1255,7 +1369,9 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
return calcState.set(CalcState::State::INVALID_START_DATE); return calcState.set(CalcState::State::INVALID_START_DATE);
} }
return calcState.set(CalcState::State::SUCCESS); //return calcState.set(CalcState::State::SUCCESS);
qCritical() << __func__ << ":" << __LINE__ << " calcState" << calcState.toString();
return calcState;
} }
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff, CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,

View File

@@ -136,6 +136,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg); static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
bool overPaid = false; bool overPaid = false;
bool successMaxPrice = false; // max-price and cost match
int paymentOptionIndex = getPaymentOptionIndex(*cfg, inputDate); int paymentOptionIndex = getPaymentOptionIndex(*cfg, inputDate);
if (paymentOptionIndex == -1) { if (paymentOptionIndex == -1) {
@@ -273,6 +274,11 @@ Calculator::GetDurationFromCost(Configuration* cfg,
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price; int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay; int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
if (cost == pop_max_price) {
qCritical() << DBG_HEADER << "SUCCESS MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
successMaxPrice = true;
}
if (cost > pop_max_price) { if (cost > pop_max_price) {
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost; qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
if (pop_allow_overpay == false) { if (pop_allow_overpay == false) {
@@ -280,6 +286,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
} }
cost = pop_max_price; cost = pop_max_price;
overPaid = true; overPaid = true;
qCritical() << DBG_HEADER << "OVERPAID, MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
// return CalcState::OVERPAID.toStdString(); // return CalcState::OVERPAID.toStdString();
} }
@@ -447,6 +454,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) { if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), d); return std::make_pair(CalcState::OVERPAID.toStdString(), d);
} }
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), d);
}
return std::make_pair(d.toString(Qt::ISODate).toStdString(), d); return std::make_pair(d.toString(Qt::ISODate).toStdString(), d);
} }
} else { } else {
@@ -523,6 +533,16 @@ Calculator::GetDurationFromCost(Configuration* cfg,
//qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate); //qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate);
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
if (pop_carry_over) {
int weekDay = inputDate.date().dayOfWeek();
int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
if (pop_carry_over_option_id != -1) {
int const carryOverDuration = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
inputDate = inputDate.addSecs(carryOverDuration * 60);
}
}
inputDate = inputDate.addSecs(durationInSecs); inputDate = inputDate.addSecs(durationInSecs);
#if DEBUG_GET_DURATION_FROM_COST==1 #if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate); qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
@@ -561,6 +581,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) { if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), inputDate); return std::make_pair(CalcState::OVERPAID.toStdString(), inputDate);
} }
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), inputDate);
}
return std::make_pair(s.toStdString(), inputDate); return std::make_pair(s.toStdString(), inputDate);
} // if ((double)price == cost) { } // if ((double)price == cost) {
else { else {
@@ -648,6 +671,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) { if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime); return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
} }
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime); return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
} else { } else {
QDateTime const dt = start; QDateTime const dt = start;
@@ -698,6 +724,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) { if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime); return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
} }
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime); return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
} }
@@ -796,6 +825,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) { if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime); return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
} }
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime); return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
} }
} }
@@ -840,6 +872,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) { if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime); return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
} }
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime); return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
} }
@@ -874,6 +909,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) { if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime); return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
} }
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime); return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
} }
@@ -993,6 +1031,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) { if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime); return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
} }
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime); return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
} }
} }

View File

@@ -10,6 +10,9 @@
#include "tariff_global_defines.h" #include "tariff_global_defines.h"
#include "tariff_settings.h" #include "tariff_settings.h"
#include "tariff_carryover_settings.h" #include "tariff_carryover_settings.h"
#include "atb_time.h"
#include "tariff_prepaid.h"
#include "tariff_carryover.h"
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
@@ -61,6 +64,405 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
ATBWeekDay WeekDay; ATBWeekDay WeekDay;
QTime start, end, parking_time_limit, about_to_exceed_limit; QTime start, end, parking_time_limit, about_to_exceed_limit;
ATBTariffCarryOverSettings::ParkingTimeLimitChecker parkTimeLimitChecker; ATBTariffCarryOverSettings::ParkingTimeLimitChecker parkTimeLimitChecker;
QDate const &d = QDate::fromString(innerObjName, Qt::ISODate);
if (innerObjName == QString("default") ||
(!d.isNull() && d.isValid())) { // special day, given in date-format
// start with new implementation of tariff-calculator
// see for instance: bad neuenahr (249), Zone5
// qCritical() << __func__ << ":" << __LINE__ << innerObjName;
if (k->value.IsObject()) {
auto obj = k->value.GetObject();
for (auto m = obj.MemberBegin(); m != obj.MemberEnd(); ++m) {
QString const &name = m->name.GetString();
if (name == "payment_settings") {
if (m->value.IsArray()) {
auto payment = m->value.GetArray();
if (payment.Size() == 0) {
qCritical() << __func__ << ":" << __LINE__ << "no payment settings for" << weekDayName;
} else {
for (rapidjson::SizeType j = 0; j < payment.Size(); ++j) {
if (payment[j].IsObject()) {
auto paymentSetting = payment[j].GetObject();
for (auto n = paymentSetting.MemberBegin(); n != paymentSetting.MemberEnd(); ++n) {
QString const &name = QString::fromStdString(n->name.GetString());
if (name == "min_time") {
if (n->value.IsInt()) { min_time = n->value.GetInt(); }
} else if (name == "max_time") {
if (n->value.IsInt()) { max_time = n->value.GetInt(); }
} else if (name == "min_price") {
if (n->value.IsInt()) { min_price = n->value.GetInt(); }
} else if (name == "max_price") {
if (n->value.IsInt()) { max_price = n->value.GetInt(); }
}
}
}
}
}
}
} else
if (name == "prepaid_settings") {
if (m->value.IsArray()) {
auto prepaid = m->value.GetArray();
if (prepaid.Size() == 0) {
qCritical() << __func__ << ":" << __LINE__ << "no prepaid-settings for" << weekDayName;
} else {
ATBTariffPrepaid TariffPrepaid;
for (rapidjson::SizeType j = 0; j < prepaid.Size(); ++j) {
if (prepaid[j].IsObject()) {
auto prepaidSetting = prepaid[j].GetObject();
for (auto n = prepaidSetting.MemberBegin(); n != prepaidSetting.MemberEnd(); ++n) {
QString const &name = QString::fromStdString(n->name.GetString());
if (name == "prepaid_ranges") {
if (n->value.IsArray()) {
auto prepaidRanges = n->value.GetArray();
if (prepaidRanges.Size() == 0) {
qCritical() << __func__ << ":" << __LINE__ << "no prepaid-ranges for" << weekDayName;
} else {
QString prepaidStartStr;
QString prepaidEndStr;
QString prepaidIf;
int prepaidDuration = -1;
for (rapidjson::SizeType i = 0; i < prepaidRanges.Size(); ++i) {
if (prepaidRanges[j].IsObject()) {
auto prepaidRange = prepaidRanges[i].GetObject();
for (auto r = prepaidRange.MemberBegin(); r != prepaidRange.MemberEnd(); ++r) {
QString const &memName = QString::fromStdString(r->name.GetString());
if (memName == "prepaid_id") {
if (r->value.IsInt()) {
TariffPrepaid.m_id = r->value.GetInt();
} else {
qCritical() << __func__ << ":" << __LINE__ << "prepaidId not an integer";
}
} else
if (memName == "prepaid_duration") {
if (r->value.IsInt()) {
prepaidDuration = r->value.GetInt();
}
} else
if (memName == "prepaid_start") {
if (r->value.IsString()) {
prepaidStartStr = QString::fromStdString(r->value.GetString());
}
} else
if (memName == "prepaid_end") {
if (r->value.IsString()) {
prepaidEndStr = QString::fromStdString(r->value.GetString());
}
} else
if (memName == "prepaid_if") {
if (r->value.IsString()) {
prepaidIf = QString::fromStdString(r->value.GetString());
}
} else {
qCritical() << __func__ << ":" << __LINE__ << "WARNING unknown prepaid setting" << memName;
}
}
}
if (!prepaidStartStr.isEmpty() && !prepaidEndStr.isEmpty() && prepaidDuration != -1) {
ATBTime prepaidStart(prepaidStartStr);
ATBTime prepaidEnd(prepaidEndStr);
if (prepaidStart.isValid() && prepaidEnd.isValid()) {
TariffPrepaid.m_range = TimeRange(prepaidStart, prepaidEnd, prepaidDuration);
TariffPrepaid.m_weekDay = weekDayName;
if (!d.isNull() && d.isValid()) {
TariffPrepaid.m_date = d;
}
TariffPrepaid.setPrepaidIf(prepaidIf);
qCritical() << TariffPrepaid;
cfg.TariffPrepaids.insert(std::pair<int, ATBTariffPrepaid>(weekDay, TariffPrepaid));
}
}
}
}
}
} else {
}
}
}
}
}
}
} else
if (name == "carry_over_settings") {
if (m->value.IsArray()) {
auto carryOver = m->value.GetArray();
if (carryOver.Size() == 0) {
qCritical() << __func__ << ":" << __LINE__ << "no carry-over-settings for" << weekDayName;
} else {
ATBTariffCarryOver TariffCarryOver;
for (rapidjson::SizeType j = 0; j < carryOver.Size(); ++j) {
if (carryOver[j].IsObject()) {
auto carryOverSetting = carryOver[j].GetObject();
for (auto n = carryOverSetting.MemberBegin(); n != carryOverSetting.MemberEnd(); ++n) {
QString const &name = QString::fromStdString(n->name.GetString());
if (name == "carry_over_ranges") {
if (n->value.IsArray()) {
auto carryOverRanges = n->value.GetArray();
if (carryOverRanges.Size() == 0) {
qCritical() << __func__ << ":" << __LINE__ << "no carry-over-ranges for" << weekDayName;
} else {
QString carryOverStartStr;
QString carryOverEndStr;
QString carryOverIf;
int carryOverDuration = -1;
for (rapidjson::SizeType i = 0; i < carryOverRanges.Size(); ++i) {
if (carryOverRanges[j].IsObject()) {
auto carryOverRange = carryOverRanges[i].GetObject();
for (auto r = carryOverRange.MemberBegin(); r != carryOverRange.MemberEnd(); ++r) {
QString const &memName = QString::fromStdString(r->name.GetString());
if (memName == "carry_over_id") {
if (r->value.IsInt()) {
TariffCarryOver.m_id = r->value.GetInt();
} else {
qCritical() << __func__ << ":" << __LINE__ << "carryOverId not an integer";
}
} else
if (memName == "carry_over_duration") {
if (r->value.IsInt()) {
carryOverDuration = r->value.GetInt();
}
} else
if (memName == "carry_over_start") {
if (r->value.IsString()) {
carryOverStartStr = QString::fromStdString(r->value.GetString());
}
} else
if (memName == "carry_over_end") {
if (r->value.IsString()) {
carryOverEndStr = QString::fromStdString(r->value.GetString());
}
} else
if (memName == "carry_over_if") {
if (r->value.IsString()) {
carryOverIf = QString::fromStdString(r->value.GetString());
}
} else {
qCritical() << __func__ << ":" << __LINE__ << "WARNING unknown carry-over setting" << memName;
}
}
}
if (!carryOverStartStr.isEmpty() && !carryOverEndStr.isEmpty() && carryOverDuration != -1) {
ATBTime carryOverStart(carryOverStartStr);
ATBTime carryOverEnd(carryOverEndStr);
if (carryOverStart.isValid() && carryOverEnd.isValid()) {
TariffCarryOver.m_range = TimeRange(carryOverStart, carryOverEnd, carryOverDuration);
TariffCarryOver.m_weekDay = weekDayName;
if (!d.isNull() && d.isValid()) {
TariffCarryOver.m_date = d;
}
if (!carryOverIf.isEmpty()) {
TariffCarryOver.setCarryOverIf(carryOverIf);
}
// qCritical() << TariffCarryOver;
cfg.TariffCarryOvers.insert(std::pair<int, ATBTariffCarryOver>(weekDay, TariffCarryOver));
}
}
}
}
}
} else {
}
}
}
}
}
}
} else
if (name == "service_settings") {
ATBTariffService TariffService;
if (m->value.IsArray()) {
auto service = m->value.GetArray();
if (service.Size() == 0) {
qCritical() << __func__ << ":" << __LINE__ << "no service settings for" << weekDayName;
} else {
for (rapidjson::SizeType j = 0; j < service.Size(); ++j) {
if (service[j].IsObject()) {
auto serviceSetting = service[j].GetObject();
for (auto n = serviceSetting.MemberBegin(); n != serviceSetting.MemberEnd(); ++n) {
QString const &name = QString::fromStdString(n->name.GetString());
if (name == "service_ranges") {
if (n->value.IsArray()) {
auto serviceRanges = n->value.GetArray();
if (serviceRanges.Size() == 0) {
qCritical() << __func__ << ":" << __LINE__ << "no service ranges for" << weekDayName;
} else {
QString serviceStartStr;
QString serviceEndStr;
QString serviceIf;
int serviceDuration = -1;
for (rapidjson::SizeType i = 0; i < serviceRanges.Size(); ++i) {
if (serviceRanges[j].IsObject()) {
auto serviceRange = serviceRanges[i].GetObject();
for (auto r = serviceRange.MemberBegin(); r != serviceRange.MemberEnd(); ++r) {
QString const &memName = QString::fromStdString(r->name.GetString());
if (memName == "service_id") {
if (r->value.IsInt()) {
TariffService.m_id = r->value.GetInt();
} else {
qCritical() << __func__ << ":" << __LINE__ << "serviceId not an integer";
}
} else
if (memName == "service_duration") {
if (r->value.IsInt()) {
serviceDuration = r->value.GetInt();
}
} else
if (memName == "service_start") {
if (r->value.IsString()) {
serviceStartStr = QString::fromStdString(r->value.GetString());
}
} else
if (memName == "service_end") {
if (r->value.IsString()) {
serviceEndStr = QString::fromStdString(r->value.GetString());
}
} else
if (memName == "service_if") {
if (r->value.IsString()) {
serviceIf = QString::fromStdString(r->value.GetString());
}
} else {
qCritical() << __func__ << ":" << __LINE__ << "WARNING unknown service setting" << memName;
}
}
}
if (!serviceStartStr.isEmpty() && !serviceEndStr.isEmpty() && serviceDuration != -1) {
ATBTime serviceStart(serviceStartStr);
ATBTime serviceEnd(serviceEndStr);
if (serviceStart.isValid() && serviceEnd.isValid()) {
TariffService.m_range = TimeRange(serviceStart, serviceEnd, serviceDuration);
TariffService.m_weekDay = weekDayName;
if (!d.isNull() && d.isValid()) {
TariffService.m_date = d;
}
if (!serviceIf.isEmpty()) {
TariffService.setServiceIf(serviceIf);
}
// qCritical() << TariffService;
cfg.TariffServices.insert(std::pair<int, ATBTariffService>(weekDay, TariffService));
}
}
}
}
}
} else {
}
}
}
}
}
}
} else
if (name == "out_of_service_settings") {
ATBTariffOutOfService TariffOutOfService;
if (m->value.IsArray()) {
auto outOfService = m->value.GetArray();
if (outOfService.Size() == 0) {
qCritical() << __func__ << ":" << __LINE__ << "no out of service settings for" << weekDayName;
} else {
for (rapidjson::SizeType j = 0; j < outOfService.Size(); ++j) {
if (outOfService[j].IsObject()) {
auto outOfServiceSetting = outOfService[j].GetObject();
for (auto n = outOfServiceSetting.MemberBegin(); n != outOfServiceSetting.MemberEnd(); ++n) {
QString const &name = QString::fromStdString(n->name.GetString());
if (name == "out_of_service_ranges") {
if (n->value.IsArray()) {
auto outOfServiceRanges = n->value.GetArray();
if (outOfServiceRanges.Size() == 0) {
qCritical() << __func__ << ":" << __LINE__ << "no out of service ranges for" << weekDayName;
} else {
QString outOfServiceStartStr;
QString outOfServiceEndStr;
QString outOfServiceIf;
int outOfServiceDuration = -1;
for (rapidjson::SizeType i = 0; i < outOfServiceRanges.Size(); ++i) {
if (outOfServiceRanges[j].IsObject()) {
auto outOfServiceRange = outOfServiceRanges[i].GetObject();
for (auto r = outOfServiceRange.MemberBegin(); r != outOfServiceRange.MemberEnd(); ++r) {
QString const &memName = QString::fromStdString(r->name.GetString());
if (memName == "out_of_service_id") {
if (r->value.IsInt()) {
TariffOutOfService.m_id = r->value.GetInt();
} else {
qCritical() << __func__ << ":" << __LINE__ << "outOfServiceId not an integer";
}
} else
if (memName == "out_of_service_duration") {
if (r->value.IsInt()) {
outOfServiceDuration = r->value.GetInt();
}
} else
if (memName == "out_of_service_start") {
if (r->value.IsString()) {
outOfServiceStartStr = QString::fromStdString(r->value.GetString());
}
} else
if (memName == "out_of_service_end") {
if (r->value.IsString()) {
outOfServiceEndStr = QString::fromStdString(r->value.GetString());
}
} else
if (memName == "out_of_service_if") {
if (r->value.IsString()) {
outOfServiceIf = QString::fromStdString(r->value.GetString());
}
} else {
qCritical() << __func__ << ":" << __LINE__ << "WARNING unknown out of service setting" << memName;
}
}
}
if (!outOfServiceStartStr.isEmpty() && !outOfServiceEndStr.isEmpty() && outOfServiceDuration != -1) {
ATBTime outOfServiceStart(outOfServiceStartStr);
ATBTime outOfServiceEnd(outOfServiceEndStr);
if (outOfServiceStart.isValid() && outOfServiceEnd.isValid()) {
TariffOutOfService.m_range = TimeRange(outOfServiceStart, outOfServiceEnd, outOfServiceDuration);
TariffOutOfService.m_weekDay = weekDayName;
if (!d.isNull() && d.isValid()) {
TariffOutOfService.m_date = d;
}
if (!outOfServiceIf.isEmpty()) {
TariffOutOfService.setOutOfServiceIf(outOfServiceIf);
}
// qCritical() << TariffOutOfService;
cfg.TariffOutOfServices.insert(std::pair<int, ATBTariffOutOfService>(weekDay, TariffOutOfService));
}
}
}
}
}
} else {
}
}
}
}
}
}
} else {
}
}
}
} else
if (innerObjName == QString("week_day_default")) { if (innerObjName == QString("week_day_default")) {
if (k->value.IsObject()) { if (k->value.IsObject()) {
auto obj = k->value.GetObject(); auto obj = k->value.GetObject();
@@ -1000,6 +1402,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
this->currentPaymentOptions.last().pop_min_time = k->value.GetDouble(); this->currentPaymentOptions.last().pop_min_time = k->value.GetDouble();
} else if (strcmp(inner_obj_name, "pop_max_price") == 0) { } else if (strcmp(inner_obj_name, "pop_max_price") == 0) {
this->currentPaymentOptions.last().pop_max_price = k->value.GetDouble(); this->currentPaymentOptions.last().pop_max_price = k->value.GetDouble();
this->currentPaymentOptions.last().pop_max_price_save = k->value.GetDouble();
} else if (strcmp(inner_obj_name, "pop_max_time") == 0) { } else if (strcmp(inner_obj_name, "pop_max_time") == 0) {
this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble(); this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
} else if (strcmp(inner_obj_name, "pop_min_price") == 0) { } else if (strcmp(inner_obj_name, "pop_min_price") == 0) {

View File

@@ -427,6 +427,8 @@ PaymentMethod Utilities::getPaymentMethodId(Configuration const *cfg) {
return PaymentMethod::Degressive; return PaymentMethod::Degressive;
case PaymentMethod::Progressive: case PaymentMethod::Progressive:
return PaymentMethod::Progressive; return PaymentMethod::Progressive;
case PaymentMethod::Unified:
return PaymentMethod::Unified;
} }
} }

View File

@@ -755,7 +755,7 @@ int main() {
int pop_max_price; int pop_max_price;
int pop_daily_card_price; int pop_daily_card_price;
int zone = 3; int zone = 1;
if (zone == 1) { if (zone == 1) {
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json"); input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json");
@@ -844,7 +844,7 @@ int main() {
CalcState calcState; CalcState calcState;
QDateTime s(QDateTime::currentDateTime()); QDateTime s(QDateTime::currentDateTime());
s.setTime(QTime(12, 0, 0)); // s.setTime(QTime(12, 0, 0));
//calcState = compute_duration_for_parking_ticket(&cfg, s, //calcState = compute_duration_for_parking_ticket(&cfg, s,
// (double)1200, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW)); // (double)1200, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
@@ -852,9 +852,26 @@ int main() {
//qCritical() << calcState.toString(); //qCritical() << calcState.toString();
calcState = compute_duration_for_parking_ticket(&cfg, s, calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)50, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS)); (double)9000, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
qCritical() << end.toString(Qt::ISODate); qCritical() << end.toString(Qt::ISODate);
qCritical() << calcState.toString(); qCritical() << calcState.toString();
struct price_t costs;
CalcState cs;
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
QDateTime end = start.addSecs(timeSteps.at(i)*60);
qCritical() << "XXXXX end" << end.toString(Qt::ISODate);
cs = compute_price_for_parking_ticket(&cfg, s, timeSteps.at(i), end, &costs,
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
if (cs.getStatus() != CalcState::State::SUCCESS) {
qCritical() << "ERROR STATUS" << costs.netto;
exit(-1);
}
}
} }
if (zone == 2) { if (zone == 2) {
@@ -1391,7 +1408,8 @@ int main() {
case 2: { case 2: {
qCritical() << " ZONE 2: KURZZEIT 1"; qCritical() << " ZONE 2: KURZZEIT 1";
// kuzzeit-1-tarif // kuzzeit-1-tarif
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json"); //input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json");
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff05.json");
//pop_max_time = 5*60; //pop_max_time = 5*60;
} break; } break;
case 3: { case 3: {
@@ -1583,7 +1601,8 @@ int main() {
break; break;
case 1: case 1:
//start = QDateTime(QDate(2024, 10, 3), QTime(17, 0, 0)); // sunday //start = QDateTime(QDate(2024, 10, 3), QTime(17, 0, 0)); // sunday
start = QDateTime(QDate(2024, 9, 8), QTime(16, 2, 0)); // sunday //start = QDateTime(QDate(2025, 4, 20), QTime(18, 0, 0)); // sunday
start = QDateTime(QDate(2024, 9, 27), QTime(17, 0, 0)); // friday
fail = false; fail = false;
break; break;
case 2: case 2:
@@ -1615,8 +1634,8 @@ int main() {
// << "START" << start.toString(Qt::ISODate) // << "START" << start.toString(Qt::ISODate)
// << "<duration" << *step; // << "<duration" << *step;
// if (*step != 180) if (*step != 180)
// continue; continue;
double cost = 0; double cost = 0;

View File

@@ -34,7 +34,12 @@ OTHER_FILES += \
/opt/ptu5/opt/customer_335/etc/psa_tariff/tariff02.json \ /opt/ptu5/opt/customer_335/etc/psa_tariff/tariff02.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json \ /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json \ /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff04.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff05.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff06.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff07.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff08.json