Compare commits

..

55 Commits

Author SHA1 Message Date
48fccafe76 Fix: GetDurationFromCost() -> set inputDate if next valid working time-range
in on another day and break the loop iterating through next days.
2024-06-06 14:04:04 +02:00
9394625d35 Minor: show debug output only when compiled in. 2024-06-06 14:02:43 +02:00
7492e37e02 Finished test for Neuhauser/Stockerau/748 2024-06-06 14:01:01 +02:00
f0dca3917c Start test-case for Neuhauser/Stockerau/748w 2024-06-05 17:05:19 +02:00
57ccbc150a compute_duration_for_parking_ticket(): set calcState according to string
returned from tariff calculation.
2024-06-05 17:03:33 +02:00
8fa4335669 Minor: fixed typo. 2024-06-05 17:03:10 +02:00
49298a1821 Extend Calculator::GetDurationFromCost() (needed for Neuhauser/Stockerau/748). 2024-06-05 17:00:27 +02:00
6fb4d245cb Added CalcState &setStatus(QString const &desc); 2024-06-05 16:58:12 +02:00
2dc93271fd Added WORKING_DAYS_WITH_RESTRICTED_HOURS (introduced for Neuhauder/Stockerau/748) 2024-06-05 16:52:54 +02:00
5be5798681 Declared iterator-arguments as const-references to get rid of compiler
warning: parameter passing for argument multi_map changed in gcc7.1
2024-06-04 11:48:50 +02:00
1a24bc4572 Add comment about main-change(s). 2024-06-04 11:39:30 +02:00
068575f8e8 improved tests 2024-06-04 11:27:57 +02:00
e121cef17e Added: uint32_t getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId); 2024-06-04 11:26:36 +02:00
bdaea1106c Fix: read price for daily ticket directly from entry PaymentOptions
in tariff-file if it is not given as part of a Json-Product-Array in tariff-file.
2024-06-04 11:24:15 +02:00
bc17213597 Minor: Add/change some debug putput. 2024-06-04 11:23:35 +02:00
64b2b4bd85 Fix: Handle case if "pop_carry_over_start_time_range" and "pop_carry_over_end_time_range"
is not given in tariff file.
2024-06-04 11:19:39 +02:00
8737508839 Minor: add case for PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET (TODO). 2024-06-04 11:18:47 +02:00
02f0500eac Minor: Add some (commented-out) debug messages. 2024-06-04 11:18:00 +02:00
2d53224feb Minor: add some (commented out) debug output -> used for debugging. 2024-05-15 15:23:12 +02:00
38964ad9a8 get_minimal_parkingprice(): for PERMIT_TYPE::DAY_TICKET
call compute_product_price(cfg, permitType, start) to get
minimal price dependent on 'start' datetime.
2024-05-15 15:21:38 +02:00
d3f18f3b82 get_minimal_parkingprice(): add default parameter 'start', set to
value of QDateTime::currentDateTime();
2024-05-15 15:19:47 +02:00
1a4265372e Add tests for Pernegg an der Mur 2024-05-15 15:19:13 +02:00
eb20410849 Use paymentOptionIndex in getPaymentOptions() 2024-05-08 16:34:07 +02:00
2a492475e3 Bad Neuenahr: Zone5 tests 2024-05-07 16:21:36 +02:00
6a5272da7a Fix: Check if endTime is still on the same day. 2024-05-07 15:01:16 +02:00
4d5583df2d Handling for pop_carry_over_traget. 2024-05-07 14:59:00 +02:00
de6f263817 Add FRI/SAT/SUN with restricted hours. 2024-05-07 14:57:41 +02:00
e4ce14da3f updated some tests 2024-05-06 11:38:37 +02:00
b71c979a91 Fix: getPaymentOptionIndex() -> return 0 instead of -1
Removed exit(0)-call which was used for testing.
2024-05-06 11:36:12 +02:00
33f43fb83d Start parsing of pop_min_date_time and pop_max_date_time 2024-05-03 13:50:10 +02:00
1606a784a4 Add macro _WEEKEND_WITH_RESTRICTED_HOURS_. 2024-05-03 13:49:15 +02:00
9f2cf613e1 Add struct ATBMaxDateTime. 2024-05-03 13:48:27 +02:00
dbd9644047 Add ATBPaymentOptionType = std::multimap<int, ATBPaymentOption> 2024-05-03 13:47:28 +02:00
f8fef12b55 Zone6 for Bad neuenahr 2024-04-30 14:09:48 +02:00
1dd81d4a56 get_minimal_parkingtime(): const Configuration parameter.
Cast of const pointer necessary.

get_maximal_parkingtime(): const Configuration parameter.
2024-04-30 14:08:08 +02:00
f93cf11d23 get_minimal_parkingtime()
get_maximal_parkingtime(): made configuration parameter const.
2024-04-30 14:06:04 +02:00
9d0ac4f8ce Add TWENTY_FOUR_HOURS_TICKET. Add toString() and implement conversion
operators in therm of toString().
2024-04-30 13:51:31 +02:00
4ec5589f30 Implement getTariffProductForProductId() in terms of
getTariffProductForProductTypeName().
2024-04-30 13:49:49 +02:00
c1d5ffcf3c Implement getTariffProductForProductTypeName().
Use the type names of PERMIT_TYPE, not real indices as they can change.
2024-04-30 13:48:03 +02:00
7aded2b7fb Explicit cast due to compiler warning. 2024-04-30 13:46:59 +02:00
ed9e60a972 Declaration for getTariffProductForProductTypeName(). 2024-04-30 13:45:22 +02:00
5d35331c83 Minor: introduced TariffProductType. 2024-04-30 13:44:53 +02:00
c7623429d9 Compute end_parking_time using "netto_parking_time", which is the
current timestep.
2024-04-25 15:41:52 +02:00
b596086245 Pass paymentOptionIndex to cfg->getPaymentOptions(), which has
a default parameter of paymentOptionIndex=0.
2024-04-24 13:20:02 +02:00
24ca857b6f Fix: init m_timeSteps-vector in case its size is 0: m_timeSteps.push_back(QList<int>()).
Detected during testing.
2024-04-24 13:18:23 +02:00
ea0bcde413 Check iterator for it != cfg->TimeRange.cend(). 2024-04-24 13:16:22 +02:00
e93b08505a Minor: introduce TimeRangeType as typedef for std::multimap<int, ATBTimeRange>. 2024-04-24 13:14:04 +02:00
44efd44ede Check paymentOptionIndex for test of GALTUER. 2024-04-24 13:11:28 +02:00
9d72574106 Minor: additional loop for test of NAZ 2024-04-24 12:01:24 +02:00
d8ec41ebfc Repeated tests for KIRCHDORF. Re-added utility test_neuhauser_kirchdorf(). Found bug during testing, accessing vector of size 0. 2024-04-24 11:56:50 +02:00
f17c4f240b Minor: add tests for special days in KORNEUBURG 2024-04-24 10:52:18 +02:00
76bb1eb56a Minor: small changes for tests of SCHOENAU 2024-04-24 09:54:29 +02:00
3b813e5eff Minor: small changes for tests of PERNEGG-AN-DER-MUR 2024-04-24 09:33:57 +02:00
436f5a109b Minor: add small changes to Christoph-Reisen 2024-04-24 09:17:26 +02:00
e17e54b315 Minor: add define: _ALL_DAYS_WITH_RESTRICTED_HOURS_ 2024-04-19 14:10:47 +02:00
12 changed files with 1900 additions and 160 deletions

View File

@@ -42,18 +42,34 @@ struct CALCULATE_LIBRARY_API price_t {
}; };
struct CALCULATE_LIBRARY_API CalcState { struct CALCULATE_LIBRARY_API CalcState {
static QString const SUCCESS;
static QString const ERROR_PARSING_ZONE_NR;
static QString const ERROR_LOADING_TARIFF;
static QString const ERROR_PARSING_TARIFF;
static QString const NEGATIVE_PARKING_TIME;
static QString const INVALID_START_DATE;
static QString const WRONG_PARAM_VALUES;
static QString const WRONG_ISO_TIME_FORMAT;
static QString const ABOVE_MAX_PARKING_TIME;
static QString const BELOW_MIN_PARKING_TIME;
static QString const BELOW_MIN_PARKING_PRICE;
static QString const ABOVE_MAX_PARKING_PRICE;
static QString const OVERPAID;
static QString const OUTSIDE_ALLOWED_PARKING_TIME;
enum class State : uint8_t { enum class State : uint8_t {
SUCCESS, SUCCESS,
ERROR_PARSING_ZONE_NR, ERROR_PARSING_ZONE_NR,
ERROR_LOADING_TARIFF, ERROR_LOADING_TARIFF,
ERROR_PARSING_TARIFF, ERROR_PARSING_TARIFF,
NEGATIVE_PARING_TIME, NEGATIVE_PARKING_TIME,
INVALID_START_DATE, INVALID_START_DATE,
WRONG_PARAM_VALUES, WRONG_PARAM_VALUES,
WRONG_ISO_TIME_FORMAT, WRONG_ISO_TIME_FORMAT,
ABOVE_MAX_PARKING_TIME, ABOVE_MAX_PARKING_TIME,
BELOW_MIN_PARKING_TIME, BELOW_MIN_PARKING_TIME,
BELOW_MIN_PARKING_PRICE, BELOW_MIN_PARKING_PRICE,
ABOVE_MAX_PARKING_PRICE,
OVERPAID, OVERPAID,
OUTSIDE_ALLOWED_PARKING_TIME OUTSIDE_ALLOWED_PARKING_TIME
}; };
@@ -88,43 +104,47 @@ struct CALCULATE_LIBRARY_API CalcState {
QString s; QString s;
switch (m_status) { switch (m_status) {
case State::SUCCESS: case State::SUCCESS:
s = "SUCCESS"; s = CalcState::SUCCESS;
break; break;
case State::ERROR_PARSING_ZONE_NR: case State::ERROR_PARSING_ZONE_NR:
s = "ERROR_PARSING_ZONE_NR"; s = CalcState::ERROR_PARSING_ZONE_NR;
break; break;
case State::ERROR_LOADING_TARIFF: case State::ERROR_LOADING_TARIFF:
s = "ERROR_LOADING_TARIFF"; s = CalcState::ERROR_LOADING_TARIFF;
break; break;
case State::ERROR_PARSING_TARIFF: case State::ERROR_PARSING_TARIFF:
s = "ERROR_PARSING_TARIFF"; s = CalcState::ERROR_PARSING_TARIFF;
break; break;
case State::NEGATIVE_PARING_TIME: case State::NEGATIVE_PARKING_TIME:
s = "NEGATIVE_PARKING_TIME"; s = CalcState::NEGATIVE_PARKING_TIME;
break; break;
case State::ABOVE_MAX_PARKING_TIME: case State::ABOVE_MAX_PARKING_TIME:
s = "ABOVE_MAX_PARKING_TIME"; s = CalcState::ABOVE_MAX_PARKING_TIME;
break; break;
case State::WRONG_PARAM_VALUES: case State::WRONG_PARAM_VALUES:
s = "WRONG_PARAM_VALUES"; s = CalcState::WRONG_PARAM_VALUES;
break; break;
case State::BELOW_MIN_PARKING_TIME: case State::BELOW_MIN_PARKING_TIME:
s = "BELOW_MIN_PARKING_TIME"; s = CalcState::BELOW_MIN_PARKING_TIME;
break; break;
case State::BELOW_MIN_PARKING_PRICE: case State::BELOW_MIN_PARKING_PRICE:
s = "BELOW_MIN_PARKING_PRICE"; s = CalcState::BELOW_MIN_PARKING_PRICE;
break; break;
case State::OVERPAID: case State::OVERPAID:
s = "OVERPAID"; s = CalcState::OVERPAID;
break; break;
case State::INVALID_START_DATE: case State::INVALID_START_DATE:
s = "INVALID_START_DATE"; s = CalcState::INVALID_START_DATE;
break; break;
case State::WRONG_ISO_TIME_FORMAT: case State::WRONG_ISO_TIME_FORMAT:
s = "WRONG_ISO_TIME_FORMAT"; s = CalcState::WRONG_ISO_TIME_FORMAT;
break; break;
case State::OUTSIDE_ALLOWED_PARKING_TIME: case State::OUTSIDE_ALLOWED_PARKING_TIME:
s = "OUTSIDE_ALLOWED_PARKING_TIME"; s = CalcState::OUTSIDE_ALLOWED_PARKING_TIME;
break;
case State::ABOVE_MAX_PARKING_PRICE:
s = CalcState::ABOVE_MAX_PARKING_TIME;
break;
} }
return s + ":" + m_desc; return s + ":" + m_desc;
} }
@@ -133,51 +153,101 @@ struct CALCULATE_LIBRARY_API CalcState {
QString s; QString s;
switch (m_status) { switch (m_status) {
case State::SUCCESS: case State::SUCCESS:
s = "SUCCESS"; s = CalcState::SUCCESS;
break; break;
case State::ERROR_PARSING_ZONE_NR: case State::ERROR_PARSING_ZONE_NR:
s = "ERROR_PARSING_ZONE_NR"; s = CalcState::ERROR_PARSING_ZONE_NR;
break; break;
case State::ERROR_LOADING_TARIFF: case State::ERROR_LOADING_TARIFF:
s = "ERROR_LOADING_TARIFF"; s = CalcState::ERROR_LOADING_TARIFF;
break; break;
case State::ERROR_PARSING_TARIFF: case State::ERROR_PARSING_TARIFF:
s = "ERROR_PARSING_TARIFF"; s = CalcState::ERROR_PARSING_TARIFF;
break; break;
case State::NEGATIVE_PARING_TIME: case State::NEGATIVE_PARKING_TIME:
s = "NEGATIVE_PARKING_TIME"; s = CalcState::NEGATIVE_PARKING_TIME;
break; break;
case State::ABOVE_MAX_PARKING_TIME: case State::ABOVE_MAX_PARKING_TIME:
s = "ABOVE_MAX_PARKING_TIME"; s = CalcState::ABOVE_MAX_PARKING_TIME;
break; break;
case State::WRONG_PARAM_VALUES: case State::WRONG_PARAM_VALUES:
s = "WRONG_PARAM_VALUES"; s = CalcState::WRONG_PARAM_VALUES;
break; break;
case State::BELOW_MIN_PARKING_TIME: case State::BELOW_MIN_PARKING_TIME:
s = "BELOW_MIN_PARKING_TIME"; s = CalcState::BELOW_MIN_PARKING_TIME;
break; break;
case State::BELOW_MIN_PARKING_PRICE: case State::BELOW_MIN_PARKING_PRICE:
s = "BELOW_MIN_PARKING_PRICE"; s = CalcState::BELOW_MIN_PARKING_PRICE;
break; break;
case State::OVERPAID: case State::OVERPAID:
s = "OVERPAID"; s = CalcState::OVERPAID;
break; break;
case State::INVALID_START_DATE: case State::INVALID_START_DATE:
s = "INVALID_START_DATE"; s = CalcState::INVALID_START_DATE;
break; break;
case State::WRONG_ISO_TIME_FORMAT: case State::WRONG_ISO_TIME_FORMAT:
s = "WRONG_ISO_TIME_FORMAT"; s = CalcState::WRONG_ISO_TIME_FORMAT;
break; break;
case State::OUTSIDE_ALLOWED_PARKING_TIME: case State::OUTSIDE_ALLOWED_PARKING_TIME:
s = "OUTSIDE_ALLOWED_PARKING_TIME"; s = CalcState::OUTSIDE_ALLOWED_PARKING_TIME;
break;
case State::ABOVE_MAX_PARKING_PRICE:
s = CalcState::ABOVE_MAX_PARKING_TIME;
break;
} }
return s + ":" + m_desc; return s + ":" + m_desc;
} }
CalcState &set(State s) { m_status = s; return *this; } CalcState &set(State s) { m_status = s; return *this; }
CalcState &setStatus(State s) { return set(s); } CalcState &setStatus(State s) { return set(s); }
CalcState &setStatus(QString const &desc) {
if (desc == SUCCESS) {
m_status = State::SUCCESS;
} else
if (desc == ERROR_PARSING_ZONE_NR) {
m_status = State::ERROR_PARSING_ZONE_NR;
} else
if (desc == ERROR_LOADING_TARIFF) {
m_status = State::SUCCESS;
} else
if (desc == ERROR_PARSING_TARIFF) {
m_status = State::ERROR_LOADING_TARIFF;
} else
if (desc == NEGATIVE_PARKING_TIME) {
m_status = State::NEGATIVE_PARKING_TIME;
} else
if (desc == INVALID_START_DATE) {
m_status = State::INVALID_START_DATE;
} else
if (desc == WRONG_PARAM_VALUES) {
m_status = State::WRONG_PARAM_VALUES;
} else
if (desc == WRONG_ISO_TIME_FORMAT) {
m_status = State::WRONG_ISO_TIME_FORMAT;
} else
if (desc == ABOVE_MAX_PARKING_TIME) {
m_status = State::ABOVE_MAX_PARKING_TIME;
} else
if (desc == BELOW_MIN_PARKING_TIME) {
m_status = State::BELOW_MIN_PARKING_TIME;
} else
if (desc == BELOW_MIN_PARKING_PRICE) {
m_status = State::BELOW_MIN_PARKING_PRICE;
} else
if (desc == OVERPAID) {
m_status = State::OVERPAID;
} else
if (desc == OUTSIDE_ALLOWED_PARKING_TIME) {
m_status = State::OUTSIDE_ALLOWED_PARKING_TIME;
} else
if (desc == ABOVE_MAX_PARKING_PRICE) {
m_status = State::ABOVE_MAX_PARKING_PRICE;
}
return *this;
}
State getStatus() const { return m_status; } State getStatus() const { return m_status; }
CalcState &setDesc(QString s) { m_desc = s; return *this; } CalcState &setDesc(QString const &s) { m_desc = s; return *this; }
void setAllowedTimeRange(QTime const &from, QTime const &until) { void setAllowedTimeRange(QTime const &from, QTime const &until) {
m_allowedTimeRange.setTimeRange(from, until); m_allowedTimeRange.setTimeRange(from, until);
@@ -197,17 +267,18 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg); QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg);
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg, int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
int paymentOptionIndex=0); int paymentOptionIndex=0);
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg, int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
int paymentOptionIndex=0); int paymentOptionIndex=0);
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
int paymentOptionIndex=0); int paymentOptionIndex = 0,
QDateTime const &start = QDateTime::currentDateTime());
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,

View File

@@ -38,6 +38,9 @@ class Configuration
public: public:
using SpecialDaysType = std::multimap<int, ATBSpecialDays>; using SpecialDaysType = std::multimap<int, ATBSpecialDays>;
using SpecialDaysWorktimeType = std::multimap<int, ATBSpecialDaysWorktime>; using SpecialDaysWorktimeType = std::multimap<int, ATBSpecialDaysWorktime>;
using TimeRangeType = std::multimap<int, ATBTimeRange>;
using TariffProductType = std::multimap<int, ATBTariffProduct>;
using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
ATBProject project; ATBProject project;
ATBCurrency Currency; ATBCurrency Currency;
@@ -51,13 +54,13 @@ public:
multimap<int, ATBWeekDays> WeekDays; multimap<int, ATBWeekDays> WeekDays;
multimap<int, ATBPeriodYear> YearPeriod; multimap<int, ATBPeriodYear> YearPeriod;
multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime; multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime;
multimap<int, ATBPaymentOption> PaymentOption; ATBPaymentOptionType PaymentOption;
multimap<int, ATBDailyTicket> DailyTicket; multimap<int, ATBDailyTicket> DailyTicket;
multimap<int, ATBTimeRange> TimeRange; TimeRangeType TimeRange;
multimap<int, ATBTimeStepConfig> TimeStepConfig; multimap<int, ATBTimeStepConfig> TimeStepConfig;
multimap<int, ATBTimeBase> TimeBase; multimap<int, ATBTimeBase> TimeBase;
multimap<int, ATBCustomer> Customer; multimap<int, ATBCustomer> Customer;
multimap<int, ATBTariffProduct> TariffProduct; TariffProductType TariffProduct;
/// <summary> /// <summary>
/// Parse JSON string /// Parse JSON string
@@ -85,6 +88,7 @@ public:
std::optional<QVector<ATBTariffProduct>> getTariffProductForAllKeys() const; std::optional<QVector<ATBTariffProduct>> getTariffProductForAllKeys() const;
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(int id) const; std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(int id) const;
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(PermitType permitType) const; std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(PermitType permitType) const;
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductTypeName(QString const &permitTypeName) const;
std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType); std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType);
std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek); std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);

View File

@@ -5,6 +5,8 @@
#include <string> #include <string>
#include <cinttypes> #include <cinttypes>
#include <QDateTime>
class ATBPaymentOption class ATBPaymentOption
{ {
public: public:
@@ -22,6 +24,7 @@ public:
pop_min_price = 0; pop_min_price = 0;
pop_max_price = 0; pop_max_price = 0;
pop_carry_over = -1; pop_carry_over = -1;
pop_carry_over_target = false;
pop_carry_over_time_range_id = -1; pop_carry_over_time_range_id = -1;
pop_carry_over_start_time_range = -1; pop_carry_over_start_time_range = -1;
pop_carry_over_end_time_range = -1; pop_carry_over_end_time_range = -1;
@@ -41,12 +44,21 @@ public:
double pop_min_price; double pop_min_price;
double pop_max_price; double pop_max_price;
int pop_carry_over; int pop_carry_over;
bool pop_carry_over_target;
int pop_carry_over_time_range_id; int pop_carry_over_time_range_id;
int pop_carry_over_start_time_range; int pop_carry_over_start_time_range;
int pop_carry_over_end_time_range; int pop_carry_over_end_time_range;
int pop_daily_card_price; int pop_daily_card_price;
uint64_t pop_business_hours; uint64_t pop_business_hours;
int pop_time_step_config; int pop_time_step_config;
struct ATBMaxDateTime {
int direction;
uint8_t week;
uint8_t day;
QTime time;
} pop_min_date_time,
pop_max_date_time;
}; };
#endif // PAYMENT_OPT_H_INCLUDED #endif // PAYMENT_OPT_H_INCLUDED

View File

@@ -8,21 +8,28 @@
#include <Qt> #include <Qt>
#define _NO_RESTRICTION_24_7_ (uint64_t)(0ULL) #define _NO_RESTRICTION_24_7_ (uint64_t)(0ULL)
#define _MON_ (uint64_t)(1ULL << 8) #define _MON_ (uint64_t)(1ULL << 8)
#define _TUE_ (uint64_t)(1ULL << 9) #define _TUE_ (uint64_t)(1ULL << 9)
#define _WED_ (uint64_t)(1ULL << 10) #define _WED_ (uint64_t)(1ULL << 10)
#define _THU_ (uint64_t)(1ULL << 11) #define _THU_ (uint64_t)(1ULL << 11)
#define _FRI_ (uint64_t)(1ULL << 12) #define _FRI_ (uint64_t)(1ULL << 12)
#define _SAT_ (uint64_t)(1ULL << 13) #define _SAT_ (uint64_t)(1ULL << 13)
#define _SUN_ (uint64_t)(1ULL << 14) #define _SUN_ (uint64_t)(1ULL << 14)
#define _WEEK_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_)) #define _WEEK_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_))
#define _WORKING_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_)) #define _WORKING_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_))
#define _ALL_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_|_SUN_)) #define _ALL_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_|_SUN_))
#define _OFFICIAL_HOLIDAY_ (uint64_t)(1ULL << 15) #define _OFFICIAL_HOLIDAY_ (uint64_t)(1ULL << 15)
#define _ONLY_WEEKEND_ ((_SAT_|_SUN_)) #define _ONLY_WEEKEND_ ((_SAT_|_SUN_))
#define _ONLY_OPEN_FOR_BUSINESS_DAYS_ (uint64_t)(1ULL << 16) /* verkaufsoffen */ #define _ONLY_OPEN_FOR_BUSINESS_DAYS_ (uint64_t)(1ULL << 16) /* verkaufsoffen */
#define _NOT_DEFINED_ (uint64_t)(~0ULL) #define _WITH_RESTRICTED_HOURS_ (uint64_t)(1ULL << 17)
#define _ALL_DAYS_WITH_RESTRICTED_HOURS_ ((_WITH_RESTRICTED_HOURS_|_ALL_DAYS_))
#define _WEEKEND_WITH_RESTRICTED_HOURS_ ((_WITH_RESTRICTED_HOURS_|_FRI_|_SAT_|_SUN_))
#define _WORKING_DAYS_WITH_RESTRICTED_HOURS_ ((_WITH_RESTRICTED_HOURS_|_WORKING_DAYS_))
#define _FRI_WITH_RESTRICTED_HOURS_ ((_WITH_RESTRICTED_HOURS_|_FRI_))
#define _SAT_WITH_RESTRICTED_HOURS_ ((_WITH_RESTRICTED_HOURS_|_SAT_))
#define _SUN_WITH_RESTRICTED_HOURS_ ((_WITH_RESTRICTED_HOURS_|_SUN_))
#define _NOT_DEFINED_ (uint64_t)(~0ULL)
enum BusinessHours : std::uint64_t enum BusinessHours : std::uint64_t
{ {
@@ -54,6 +61,12 @@ enum BusinessHours : std::uint64_t
OFFICIAL_HOLIDAY = _OFFICIAL_HOLIDAY_, OFFICIAL_HOLIDAY = _OFFICIAL_HOLIDAY_,
ONLY_WEEKEND = _ONLY_WEEKEND_, ONLY_WEEKEND = _ONLY_WEEKEND_,
ONLY_OPEN_FOR_BUSINESS_DAYS = _ONLY_OPEN_FOR_BUSINESS_DAYS_, ONLY_OPEN_FOR_BUSINESS_DAYS = _ONLY_OPEN_FOR_BUSINESS_DAYS_,
ALL_DAYS_WITH_RESTRICTED_HOURS = _ALL_DAYS_WITH_RESTRICTED_HOURS_,
WEEKEND_WITH_RESTRICTED_HOURS = _WEEKEND_WITH_RESTRICTED_HOURS_,
WORKING_DAYS_WITH_RESTRICTED_HOURS = _WORKING_DAYS_WITH_RESTRICTED_HOURS_,
FRI_WITH_RESTRICTED_HOURS = _FRI_WITH_RESTRICTED_HOURS_,
SAT_WITH_RESTRICTED_HOURS = _SAT_WITH_RESTRICTED_HOURS_,
SUN_WITH_RESTRICTED_HOURS = _SUN_WITH_RESTRICTED_HOURS_,
NOT_DEFINED = _NOT_DEFINED_ NOT_DEFINED = _NOT_DEFINED_
}; };

View File

@@ -4,15 +4,16 @@
#include <QString> #include <QString>
enum class PERMIT_TYPE : quint8 { enum class PERMIT_TYPE : quint8 {
SHORT_TERM_PARKING, SHORT_TERM_PARKING=0,
DAY_TICKET, DAY_TICKET=1,
SZEGED_START, SZEGED_START=2,
SZEGED_STOP, SZEGED_STOP=3,
DAY_TICKET_ADULT, DAY_TICKET_ADULT=4,
DAY_TICKET_TEEN, DAY_TICKET_TEEN=5,
DAY_TICKET_CHILD, DAY_TICKET_CHILD=6,
FOOD_STAMP, INVALID=7,
INVALID FOOD_STAMP=8,
TWENTY_FOUR_HOURS_TICKET=9
}; };
struct PermitType { struct PermitType {
@@ -45,6 +46,9 @@ struct PermitType {
case 7: case 7:
m_permitType = PERMIT_TYPE::FOOD_STAMP; m_permitType = PERMIT_TYPE::FOOD_STAMP;
break; break;
case 8:
m_permitType = PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET;
break;
default: default:
m_permitType = PERMIT_TYPE::INVALID; m_permitType = PERMIT_TYPE::INVALID;
} }
@@ -74,6 +78,8 @@ struct PermitType {
return 6; return 6;
case PERMIT_TYPE::FOOD_STAMP: case PERMIT_TYPE::FOOD_STAMP:
return 7; return 7;
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
return 8;
default: default:
break; break;
} }
@@ -81,7 +87,7 @@ struct PermitType {
} }
operator QString () { QString toString() {
switch(m_permitType) { switch(m_permitType) {
case PERMIT_TYPE::DAY_TICKET: case PERMIT_TYPE::DAY_TICKET:
return QString("DAY_TICKET"); return QString("DAY_TICKET");
@@ -99,13 +105,15 @@ struct PermitType {
return QString("SZEGED_STOP"); return QString("SZEGED_STOP");
case PERMIT_TYPE::FOOD_STAMP: case PERMIT_TYPE::FOOD_STAMP:
return QString("FOOD_STAMP"); return QString("FOOD_STAMP");
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
return QString("TWENTY_FOUR_HOURS_TICKET");
default: default:
break; break;
} }
return QString("INVALID"); return QString("INVALID");
} }
operator QString () const { QString toString() const {
switch(m_permitType) { switch(m_permitType) {
case PERMIT_TYPE::DAY_TICKET: case PERMIT_TYPE::DAY_TICKET:
return QString("DAY_TICKET"); return QString("DAY_TICKET");
@@ -123,11 +131,21 @@ struct PermitType {
return QString("SZEGED_STOP"); return QString("SZEGED_STOP");
case PERMIT_TYPE::FOOD_STAMP: case PERMIT_TYPE::FOOD_STAMP:
return QString("FOOD_STAMP"); return QString("FOOD_STAMP");
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
return QString("TWENTY_FOUR_HOURS_TICKET");
default: default:
break; break;
} }
return QString("INVALID"); return QString("INVALID");
} }
operator QString () {
return toString();
}
operator QString () const {
return toString();
}
}; };
#endif // TARIFF_PERMIT_TYPE_H_INCLUDED #endif // TARIFF_PERMIT_TYPE_H_INCLUDED

View File

@@ -79,12 +79,12 @@ namespace Utilities {
double CalculatePricePerUnit(double pra_price, double durationUnit = -1); double CalculatePricePerUnit(double pra_price, double durationUnit = -1);
QTime SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDayId); QTime SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDayId);
QTime SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator it); QTime SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator const &it);
QTime SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId); QTime SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId);
QTime SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator it); QTime SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator const &it);
QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr); QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr); QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr); int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
// PaymentRate GetPaymentRate(Configuration const *cfg, ); // PaymentRate GetPaymentRate(Configuration const *cfg, );
bool isCarryOverSet(Configuration const *cfg, PaymentMethod paymentMethodId); bool isCarryOverSet(Configuration const *cfg, PaymentMethod paymentMethodId);
bool isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymentMethodId); bool isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymentMethodId);
@@ -100,4 +100,5 @@ namespace Utilities {
uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id); uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id); double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
QStringList dumpBusinessHours(uint64_t businessHours); QStringList dumpBusinessHours(uint64_t businessHours);
uint32_t getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId);
} }

View File

@@ -12,6 +12,10 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/include/rapidjson
#Version is set in yocto recipe with "EXTRA_QMAKEVARS_PRE" #Version is set in yocto recipe with "EXTRA_QMAKEVARS_PRE"
#VERSION=1.0.0 #VERSION=1.0.0
# 04.06.2024: Fix for Szeged: read price for daily ticket directly from entry
# PaymentOptions in tariff-file if it is not given as part of a
# Json-Product-Array in tariff-file.
CONFIG(debug, debug|release) { CONFIG(debug, debug|release) {
win32 { win32 {
QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS

View File

@@ -10,11 +10,26 @@
#include <QDebug> #include <QDebug>
#include <QList> #include <QList>
QString const CalcState::SUCCESS = "SUCCESS";
QString const CalcState::ERROR_PARSING_ZONE_NR = "ERROR_PARSING_ZONE_NR";
QString const CalcState::ERROR_LOADING_TARIFF = "ERROR_LOADING_TARIFF";
QString const CalcState::ERROR_PARSING_TARIFF = "ERROR_PARSING_TARIFF";
QString const CalcState::NEGATIVE_PARKING_TIME = "NEGATIVE_PARKING_TIME";
QString const CalcState::INVALID_START_DATE = "INVALID_START_DATE";
QString const CalcState::WRONG_PARAM_VALUES = "WRONG_PARAM_VALUES";
QString const CalcState::WRONG_ISO_TIME_FORMAT = "WRONG_ISO_TIME_FORMAT";
QString const CalcState::ABOVE_MAX_PARKING_TIME = "ABOVE_MAX_PARKING_TIME";
QString const CalcState::BELOW_MIN_PARKING_TIME = "BELOW_MIN_PARKING_TIME";
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::OVERPAID = "OVERPAID";
QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME";
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);
} }
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg, int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
PERMIT_TYPE permitType, PERMIT_TYPE permitType,
int paymentOptionIndex) { int paymentOptionIndex) {
int minTime = 0; int minTime = 0;
@@ -33,14 +48,14 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg,
// for each new sell-procedure, recomute the timesteps. implicitly, set // for each new sell-procedure, recomute the timesteps. implicitly, set
// the minimal parking time. // the minimal parking time.
Calculator::GetInstance().ResetTimeSteps(paymentOptionIndex); Calculator::GetInstance().ResetTimeSteps(paymentOptionIndex);
Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex); Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time); minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
} }
return minTime; return minTime;
} }
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg, int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
PERMIT_TYPE permitType, PERMIT_TYPE permitType,
int paymentOptionIndex) { int paymentOptionIndex) {
int maxTime = 0; int maxTime = 0;
@@ -59,11 +74,13 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg,
} }
return maxTime; return maxTime;
} }
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
PERMIT_TYPE permitType, PERMIT_TYPE permitType,
int paymentOptionIndex) { int paymentOptionIndex,
QDateTime const &start) {
int minPrice = -1; int minPrice = -1;
switch(permitType) { switch(permitType) {
@@ -76,6 +93,9 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
} break; } break;
case PERMIT_TYPE::DAY_TICKET_CHILD: { case PERMIT_TYPE::DAY_TICKET_CHILD: {
} break; } break;
case PERMIT_TYPE::DAY_TICKET: {
minPrice = compute_product_price(cfg, permitType, start);
} break;
default: ; default: ;
} }
@@ -144,6 +164,10 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
QTime const &startTime = p.getTimeStart(); QTime const &startTime = p.getTimeStart();
QTime const &endTime = p.getTimeEnd(); QTime const &endTime = p.getTimeEnd();
// qCritical() << __LINE__ << startTime.toString(Qt::ISODate);
// qCritical() << __LINE__ << endTime.toString(Qt::ISODate);
// qCritical() << __LINE__ << start.toString(Qt::ISODate);
if (start.time() >= startTime && start.time() < endTime) { if (start.time() >= startTime && start.time() < endTime) {
product_price = p.getProductPrice(); product_price = p.getProductPrice();
if (productStart && productEnd) { if (productStart && productEnd) {
@@ -154,8 +178,41 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
} }
return product_price; return product_price;
} else {
// SZEGED
int const pop_daily_card_price = cfg->getPaymentOptions().pop_daily_card_price;
qDebug() << QString("(%1:%2) no products defined in tariff-file").arg(__func__).arg(__LINE__);
qDebug() << QString("(%1:%2) pop_daily_card_price=%3").arg(__func__).arg(__LINE__).arg(pop_daily_card_price);
// static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
// return Utilities::getDailyTicketCardPrice(cfg, paymentMethodId);
return pop_daily_card_price;
} }
} break; } break;
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
if (products) {
int product_price = 0;
QVector<ATBTariffProduct> product = products.value();
if (product.size() > 0) {
if (productStart && productEnd) {
int pop_min_time = get_minimal_parkingtime(cfg); // in minutes
int pop_max_time = get_maximal_parkingtime(cfg); // in minutes
if (pop_max_time >= pop_min_time) {
*productStart = start;
*productEnd = start.addSecs(pop_max_time*60);
product_price = product[0].getProductPrice();
}
}
}
return product_price;
}
} break;
default: default:
break; break;
} }
@@ -396,7 +453,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
if (duration < 0) { if (duration < 0) {
calcState.setDesc(QString("end=%1, start=%2") calcState.setDesc(QString("end=%1, start=%2")
.arg(end_parking_time, start_parking_time)); .arg(end_parking_time, start_parking_time));
return calcState.set(CalcState::State::NEGATIVE_PARING_TIME); return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
} }
if (duration > maxMin) { if (duration > maxMin) {
calcState.setDesc(QString("duration=%1, maxMin=%2").arg(duration).arg(maxMin)); calcState.setDesc(QString("duration=%1, maxMin=%2").arg(duration).arg(maxMin));
@@ -453,6 +510,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
// DEBUG // DEBUG
qCritical() << "compute_price_for_parking_ticket() " << endl qCritical() << "compute_price_for_parking_ticket() " << endl
<< " paymentOptionIndex: " << paymentOptionIndex << endl
<< " start_parking_time: " << start_parking_time << endl << " start_parking_time: " << start_parking_time << endl
<< " netto_parking_time: " << netto_parking_time << endl << " netto_parking_time: " << netto_parking_time << endl
<< " minMin: " << minMin << endl << " minMin: " << minMin << endl
@@ -463,7 +521,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
calcState.setDesc(QString("end=%1, start=%2") calcState.setDesc(QString("end=%1, start=%2")
.arg(end_parking_time.toString(Qt::ISODate), .arg(end_parking_time.toString(Qt::ISODate),
start_parking_time.toString(Qt::ISODate))); start_parking_time.toString(Qt::ISODate)));
return calcState.set(CalcState::State::NEGATIVE_PARING_TIME); return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
} }
if (netto_parking_time > maxMin) { if (netto_parking_time > maxMin) {
calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin)); calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin));
@@ -479,14 +537,21 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
double cost = -1; double cost = -1;
if (start_parking_time.isValid()) { if (start_parking_time.isValid()) {
if (tariff->getPaymentOptions().pop_payment_method_id == PaymentMethod::Steps) { if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps) {
// hier muesste man unterscheiden: uebertrag oder nicht? // hier muesste man unterscheiden: uebertrag oder nicht?
calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time, calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time,
netto_parking_time, paymentOptionIndex); netto_parking_time, paymentOptionIndex);
if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) { if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
// << calcState.toString();
return calcState; return calcState;
} }
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex); cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
end_parking_time = start_parking_time.addSecs(netto_parking_time*60);
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
// << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
} else { } else {
cost = Calculator::GetInstance().GetCostFromDuration( cost = Calculator::GetInstance().GetCostFromDuration(
tariff, tariff,
@@ -503,7 +568,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
} }
// DEBUG // DEBUG
qCritical() << " -> calculated cost (price->netto) = " << cost; qCritical() << " end_parking_time: " << end_parking_time;
qCritical() << " -> calculated cost (netto): " << cost;
price->brutto = price->vat = price->vat_percentage = 0; price->brutto = price->vat = price->vat_percentage = 0;
price->units = cost; price->units = cost;
@@ -564,16 +630,76 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
tariff->getPaymentOptions().pop_payment_method_id, tariff->getPaymentOptions().pop_payment_method_id,
cs.toLocal8Bit().constData(), cs.toLocal8Bit().constData(),
price, false, true).c_str(); price, false, true).c_str();
ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
// DEBUG if (endTime == CalcState::SUCCESS) {
qCritical() << "compute_duration_for_parking_ticket(): "; calcState.setDesc(QString("SUCCESS"));
qCritical() << " endTime: " << endTime; calcState.setStatus(endTime);
qCritical() << " ticketEndTime: " << ticketEndTime; } else
if (endTime == CalcState::ERROR_PARSING_ZONE_NR) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::ERROR_LOADING_TARIFF) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::ERROR_PARSING_TARIFF) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::NEGATIVE_PARKING_TIME) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::INVALID_START_DATE) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::WRONG_PARAM_VALUES) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::WRONG_ISO_TIME_FORMAT) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::ABOVE_MAX_PARKING_TIME) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::BELOW_MIN_PARKING_TIME) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::BELOW_MIN_PARKING_PRICE) {
calcState.setStatus(endTime);
return calcState;
} else
if (endTime == CalcState::ABOVE_MAX_PARKING_PRICE) {
calcState.setDesc(CalcState::ABOVE_MAX_PARKING_PRICE);
calcState.setStatus(CalcState::ABOVE_MAX_PARKING_PRICE);
return calcState;
} else
if (endTime == CalcState::OVERPAID) {
calcState.setDesc(CalcState::OVERPAID);
calcState.setStatus(CalcState::OVERPAID);
return calcState;
} else
if (endTime == CalcState::OUTSIDE_ALLOWED_PARKING_TIME) {
calcState.setStatus(endTime);
return calcState;
} else {
ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
if (!ticketEndTime.isValid()) { // DEBUG
calcState.setDesc(QString("ticketEndTime=%1").arg(endTime)); //qCritical() << "compute_duration_for_parking_ticket(): ";
return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT); //qCritical() << " endTime: " << endTime;
//qCritical() << " ticketEndTime: " << ticketEndTime;
if (!ticketEndTime.isValid()) {
calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
}
} }
} else { } else {
return calcState.set(CalcState::State::INVALID_START_DATE); return calcState.set(CalcState::State::INVALID_START_DATE);

View File

@@ -144,7 +144,228 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
} }
} }
qCritical() << __func__ << ":" << __LINE__ << "NOT YET IMPLEMENTED"; // TODO: man braucht den richtigen Index
int paymentOptionIndex = 0;
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
if (cost > pop_max_price) {
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
return CalcState::OVERPAID.toStdString();
}
if (cost < pop_min_price) {
qCritical() << DBG_HEADER << "MIN-PARKING-PRICE" << pop_min_price << ", COST" << cost;
return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
}
// int const pop_pre_paid = 1;
if (prepaid) {
// no limits on pre-pay-option, i.e. pre-pay-ranges are exactly
// the complements of operational-ranges
// find out if we are in a pre-pay-range.
// in this case, adapt inputDate accordingly.
// #define DEBUG_GET_DURATION_FROM_COST 1
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "PRE-PAID-OPTION: ADAPT-INPUT-DATE" << inputDate.toString(Qt::ISODate);
#endif
QTime currentTime = inputDate.time();
int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
bool useWeekDaysWorkTimeOfOtherDay = true;
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(pwd_period_day_in_week_id); iter != rEnd; ++iter) {
QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
QTime pwd_time_to = QTime::fromString(QString::fromStdString(iter->second.pwd_time_to), Qt::ISODate);
if (inputDate.time() < pwd_time_from) {
inputDate.setTime(pwd_time_from);
useWeekDaysWorkTimeOfOtherDay = false;
break;
}
if (currentTime <= pwd_time_to) {
useWeekDaysWorkTimeOfOtherDay = false;
break;
}
}
if (useWeekDaysWorkTimeOfOtherDay) {// for the current day, we are above
// the latest worktime-range -> find the next valid range
QTime pwd_time_from_next_valid_range(0, 0, 0);
int pwd_period_next_day_in_week_id = pwd_period_day_in_week_id;
for (int days = 1; days < 8; ++days) {
pwd_period_next_day_in_week_id += 1;
if (pwd_period_next_day_in_week_id > (int)Qt::Sunday) {
pwd_period_next_day_in_week_id = Qt::Monday;
}
if (cfg->WeekDaysWorktime.count(pwd_period_next_day_in_week_id) > 0) {
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(pwd_period_next_day_in_week_id); iter != rEnd; ++iter) {
QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
if (pwd_time_from_next_valid_range < pwd_time_from) {
pwd_time_from_next_valid_range = pwd_time_from;
break;
}
}
inputDate = inputDate.addDays(days);
inputDate.setTime(pwd_time_from_next_valid_range);
break;
}
}
}
}
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "(ADAPTED) INPUT-DATE" << inputDate.toString(Qt::ISODate);
#endif
// inputDate is now located in a valid operational-working-range
// find this working-time-range
int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
if (cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id) == 0) {
qCritical() << DBG_HEADER
<< "ERROR" << inputDate.toString(Qt::ISODate)
<< "NOT IN VALID WORKING TIME-RANGE";
return "";
}
QTime current_working_time_from;
QTime current_working_time_to;
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(pwd_period_day_in_week_id); iter != rEnd; ++iter) {
QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
QTime pwd_time_to = QTime::fromString(QString::fromStdString(iter->second.pwd_time_to), Qt::ISODate);
if (pwd_time_from <= inputDate.time() && inputDate.time() <= pwd_time_to) {
current_working_time_from = pwd_time_from;
current_working_time_to = pwd_time_to;
}
}
if (current_working_time_from.isNull() || current_working_time_to.isNull()) {
// can never happen
qCritical() << DBG_HEADER
<< "ERROR" << inputDate.toString(Qt::ISODate)
<< "NOT IN VALID WORKING TIME-RANGE";
return "";
}
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "CURRENT WORKING-TIME-FROM" << current_working_time_from.toString(Qt::ISODate);
qCritical() << DBG_HEADER << " CURRENT WORKING-TIME-TO" << current_working_time_to.toString(Qt::ISODate);
#endif
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const pra_price = itr->second.pra_price;
if ((double)pra_price == cost) {
int const durationId = itr->second.pra_payment_unit_id;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
// found now the duration in minutes
// check if we are still inside the working-time-range
ATBDuration duration = search->second;
int durationInSecs = duration.pun_duration * 60;
QDateTime current_working_date_time_to = inputDate;
current_working_date_time_to.setTime(current_working_time_to);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "DURATION IN MINUTES" << duration.pun_duration;
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << duration.pun_duration * 60;
qCritical() << DBG_HEADER << "CURRENT-WORKING-DATE-TIME-TO"
<< current_working_date_time_to.toString(Qt::ISODate);
qCritical() << DBG_HEADER << "NEW INPUT DATE" << inputDate.addSecs(durationInSecs).toString(Qt::ISODate);
#endif
if (inputDate.addSecs(durationInSecs) > current_working_date_time_to) {
QTime next_working_time_from;
if (cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over != 0) {
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "CARRY-OVER SET";
#endif
// check for next working-time-range on same day
int day_in_week_id = inputDate.date().dayOfWeek();
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(day_in_week_id); iter != rEnd; ++iter) {
QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
if (pwd_time_from > current_working_time_to) {
next_working_time_from = pwd_time_from;
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "NEXT-WORKING-TIME-FROM"
<< next_working_time_from.toString(Qt::ISODate);
#endif
break;
}
}
// check for next working-time-range on following day(s)
if (next_working_time_from.isNull()) {
next_working_time_from = QTime(0, 0, 0);
for (int days = 1; days < 8; ++days) {
day_in_week_id += 1;
if (day_in_week_id > (int)Qt::Sunday) {
day_in_week_id = Qt::Monday;
}
if (cfg->WeekDaysWorktime.count(day_in_week_id) > 0) {
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(day_in_week_id); iter != rEnd; ++iter) {
QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
if (next_working_time_from < pwd_time_from) {
next_working_time_from = pwd_time_from;
break;
}
}
QDateTime upper = inputDate.addDays(days);
upper.setTime(next_working_time_from);
QDateTime lower = inputDate;
lower.setTime(current_working_time_to);
inputDate = inputDate.addSecs(lower.secsTo(upper) + durationInSecs);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
#endif
break;
}
} // for (int days = 1; days < 8; ++days) {
} else { // next working-time is on same day
QDateTime upper = inputDate;
upper.setTime(next_working_time_from);
QDateTime lower = inputDate;
lower.setTime(current_working_time_to);
inputDate = inputDate.addSecs(lower.secsTo(upper) + durationInSecs);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
#endif
}
}
} else {
inputDate = inputDate.addSecs(duration.pun_duration * 60);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "INPUT-DATE" << inputDate.toString(Qt::ISODate);
#endif
}
QString const &s = inputDate.toString(Qt::ISODate);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "TICKET-END" << s;
#endif
return s.toStdString();
}
}
}
return ""; return "";
} }
} }
@@ -628,12 +849,19 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg); PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
if (paymentMethodId == PaymentMethod::Steps) { if (paymentMethodId == PaymentMethod::Steps) {
uint64_t const businessHours = cfg->getPaymentOptions(paymentOptionIndex).pop_business_hours; uint64_t const businessHours = cfg->getPaymentOptions(paymentOptionIndex).pop_business_hours;
if (cfg->isDayIncluded(businessHours, start)) { if (cfg->isDayIncluded(businessHours, start)) {
if (businessHours == BusinessHours::NO_RESTRICTION_24_7) { if (businessHours == BusinessHours::NO_RESTRICTION_24_7) {
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
QTime(0, 0, 0), QTime(23, 59, 59)); QTime(0, 0, 0), QTime(23, 59, 59));
} }
int const weekdayId = start.date().dayOfWeek(); int const weekdayId = start.date().dayOfWeek();
// qCritical() << DBG_HEADER
// << "weekdayId" << weekdayId
// << "count" << cfg->WeekDaysWorktime.count(weekdayId);
if (cfg->WeekDaysWorktime.count(weekdayId) > 0) { if (cfg->WeekDaysWorktime.count(weekdayId) > 0) {
using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator; using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId); std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
@@ -649,8 +877,10 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
QTime const &startTime = start.time(); QTime const &startTime = start.time();
if (startTime >= from && startTime <= until) { if (startTime >= from && startTime <= until) {
QTime const endTime = start.addSecs(netto_parking_time*60).time(); QDateTime const end = start.addSecs(netto_parking_time*60);
if (endTime <= until) { QTime const endTime = end.time();
if (endTime <= until && start.date().dayOfWeek() == end.date().dayOfWeek()) {
qCritical() << DBG_HEADER;
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", from, until); return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", from, until);
} else { } else {
errorStr = QString("%1 startTime not in range (%2 not in [%3, %4))") errorStr = QString("%1 startTime not in range (%2 not in [%3, %4))")
@@ -668,28 +898,59 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
} }
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over; int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
// qCritical() << DBG_HEADER
// << "paymentOptionIndex" << paymentOptionIndex
// << "pop_carry_over" << pop_carry_over;
if (pop_carry_over == 1) { if (pop_carry_over == 1) {
qCritical() << DBG_HEADER // qCritical() << DBG_HEADER
<< "NO. CHECK IF PARKING IS ALLOWED WITH CARRY-OVER ..."; // << "NO. CHECK IF PARKING IS ALLOWED WITH CARRY-OVER ...";
int const pop_carry_over_start_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_start_time_range; int const pop_carry_over_start_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_start_time_range;
int const pop_carry_over_end_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_end_time_range; int const pop_carry_over_end_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_end_time_range;
// qCritical() << DBG_HEADER
// << "pop_carry_over_start_time_range" << pop_carry_over_start_time_range
// << "pop_carry_over_end_time_range" << pop_carry_over_end_time_range;
if ((int)cfg->TimeRange.count(pop_carry_over_start_time_range) <= 0 &&
(int)cfg->TimeRange.count(pop_carry_over_end_time_range) <= 0) {
qCritical() << DBG_HEADER << "PARKING_ALLOWED. startTime" << startTime.toString(Qt::ISODate);
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", startTime);
} else
// search entry in time-range-field of tariff-file
if (cfg->TimeRange.count(pop_carry_over_start_time_range) == 1 && if (cfg->TimeRange.count(pop_carry_over_start_time_range) == 1 &&
cfg->TimeRange.count(pop_carry_over_end_time_range) == 1) { cfg->TimeRange.count(pop_carry_over_end_time_range) == 1) {
ATBTimeRange s = cfg->TimeRange.find(pop_carry_over_start_time_range)->second; ATBTimeRange s = cfg->TimeRange.find(pop_carry_over_start_time_range)->second;
ATBTimeRange e = cfg->TimeRange.find(pop_carry_over_end_time_range)->second; ATBTimeRange e = cfg->TimeRange.find(pop_carry_over_end_time_range)->second;
// qCritical() << DBG_HEADER
// << "startTime" << startTime.toString(Qt::ISODate);
if (startTime >= s.getTimeFrom() && startTime <= s.getTimeUntil()) { if (startTime >= s.getTimeFrom() && startTime <= s.getTimeUntil()) {
QDateTime sd = start; QDateTime sd = start;
sd.setTime(s.getTimeUntil()); sd.setTime(s.getTimeUntil());
// qCritical() << DBG_HEADER << "jumpFrom" << sd.toString(Qt::ISODate);
QDateTime ed = start.addDays(1); QDateTime ed = start.addDays(1);
ed.setTime(e.getTimeFrom()); ed.setTime(e.getTimeFrom());
// qCritical() << DBG_HEADER << "to" << ed.toString(Qt::ISODate);
int const jumpSecs = sd.secsTo(ed); int const jumpSecs = sd.secsTo(ed);
// qCritical() << DBG_HEADER << "jumpSecs" << jumpSecs;
QDateTime const end = start.addSecs(netto_parking_time*60 + jumpSecs); QDateTime const end = start.addSecs(netto_parking_time*60 + jumpSecs);
// qCritical() << DBG_HEADER << "new end" << end.toString(Qt::ISODate);
if (end.time() <= e.getTimeUntil()) { if (end.time() <= e.getTimeUntil()) {
qCritical() << DBG_HEADER qCritical() << DBG_HEADER
@@ -699,13 +960,13 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
startTime, end.time()); startTime, end.time());
} else { } else {
errorStr = QString("endTime %1 exceeds [%2, %3))") errorStr = QString("endTime %1 outside [%2, %3))")
.arg(end.toString(Qt::ISODate)) .arg(end.toString(Qt::ISODate))
.arg(sd.toString(Qt::ISODate)) .arg(sd.toString(Qt::ISODate))
.arg(ed.toString(Qt::ISODate)); .arg(ed.toString(Qt::ISODate));
} }
} else { } else {
errorStr = QString("startTime %1 exceeds [%2, %3))") errorStr = QString("startTime %1 outside [%2, %3))")
.arg(startTime.toString(Qt::ISODate)) .arg(startTime.toString(Qt::ISODate))
.arg(s.getTimeFrom().toString(Qt::ISODate)) .arg(s.getTimeFrom().toString(Qt::ISODate))
.arg(s.getTimeUntil().toString(Qt::ISODate)); .arg(s.getTimeUntil().toString(Qt::ISODate));
@@ -728,6 +989,8 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
} }
} }
qCritical() << DBG_HEADER << "errorStr" << errorStr;
return CalcState(CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME, errorStr, return CalcState(CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME, errorStr,
QTime(), QTime()); QTime(), QTime());
} }
@@ -1833,6 +2096,8 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
if (m_timeSteps.size() > paymentOptionIndex) { if (m_timeSteps.size() > paymentOptionIndex) {
//qCritical() << __PRETTY_FUNCTION__ << "timeSteps:" << m_timeSteps; //qCritical() << __PRETTY_FUNCTION__ << "timeSteps:" << m_timeSteps;
return m_timeSteps[paymentOptionIndex]; return m_timeSteps[paymentOptionIndex];
} else {
m_timeSteps.push_back(QList<int>());
} }
QDateTime start = QDateTime::currentDateTime(); QDateTime start = QDateTime::currentDateTime();
@@ -1888,7 +2153,7 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
qCritical() << "(" << __func__ << ":" << __LINE__ << ") configured minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time; qCritical() << "(" << __func__ << ":" << __LINE__ << ") configured minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
// set dynamic minimal parking time // set dynamic minimal parking time
cfg->getPaymentOptions().pop_min_time = timeStep; cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = timeStep;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time; qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
@@ -2003,6 +2268,9 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
if (dailyTickets) { if (dailyTickets) {
QVector<ATBDailyTicket> const tickets = dailyTickets.value(); QVector<ATBDailyTicket> const tickets = dailyTickets.value();
switch (permitType) { switch (permitType) {
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
// TODO
} break;
case PERMIT_TYPE::FOOD_STAMP: { case PERMIT_TYPE::FOOD_STAMP: {
// TODO // TODO
} break; } break;

View File

@@ -9,6 +9,7 @@
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
#include <QRegularExpression>
/// <inheritdoc/> /// <inheritdoc/>
MemberType Configuration::IdentifyJsonMember(const char* member_name) MemberType Configuration::IdentifyJsonMember(const char* member_name)
@@ -436,6 +437,60 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
} }
} else if (strcmp(inner_obj_name, "pop_time_step_config") == 0) { } else if (strcmp(inner_obj_name, "pop_time_step_config") == 0) {
this->currentPaymentOptions.last().pop_time_step_config = k->value.GetInt(); this->currentPaymentOptions.last().pop_time_step_config = k->value.GetInt();
} else if ((strcmp(inner_obj_name, "pop_min_date_time") == 0)
|| (strcmp(inner_obj_name, "pop_max_date_time") == 0)) {
if (k->value.IsString()) { // -w0dFriT16:20:00 or +w0dMonT00:00:00
static const QRegularExpression re(R"(([+-])w([0-9]+)d([A-Za-z]{3})T([0-9]{2}:[0-9]{2}:[0-9]{2}))");
QString const &s = QString::fromStdString(k->value.GetString());
QRegularExpressionMatch match = re.match(s);
if (match.hasMatch()) {
ATBPaymentOption::ATBMaxDateTime dt;
int lastCaptured = match.lastCapturedIndex();
if (lastCaptured == 4) {
dt.direction = (match.captured(1) == "-") ? -1 : +1;
bool ok;
uint8_t week = match.captured(2).toUInt(&ok);
if (ok) {
dt.week = week;
}
QString const &day = match.captured(3);
if (day.compare("Mon", Qt::CaseInsensitive) == 0) {
dt.day = (int)Qt::Monday;
} else if (day.compare("Tue", Qt::CaseInsensitive) == 0) {
dt.day = (int)Qt::Tuesday;
} else if (day.compare("Wed", Qt::CaseInsensitive) == 0) {
dt.day = (int)Qt::Wednesday;
} else if (day.compare("Thu", Qt::CaseInsensitive) == 0) {
dt.day = (int)Qt::Thursday;
} else if (day.compare("Fri", Qt::CaseInsensitive) == 0) {
dt.day = (int)Qt::Friday;
} else if (day.compare("Sat", Qt::CaseInsensitive) == 0) {
dt.day = (int)Qt::Saturday;
} else if (day.compare("Sun", Qt::CaseInsensitive) == 0) {
dt.day = (int)Qt::Sunday;
}
QTime t = QTime::fromString(match.captured(4), Qt::ISODate);
if (t.isValid()) {
dt.time = t;
}
}
if (strcmp(inner_obj_name, "pop_min_date_time") == 0) {
this->currentPaymentOptions.last().pop_min_date_time = dt;
} else
if (strcmp(inner_obj_name, "pop_max_date_time") == 0) {
this->currentPaymentOptions.last().pop_max_date_time = dt;
}
}
}
} else if (strcmp(inner_obj_name, "pop_carry_over_target") == 0) {
if (k->value.IsBool()) {
bool const v = k->value.GetBool();
this->currentPaymentOptions.last().pop_carry_over_target = v;
}
} }
break; break;
case MemberType::DurationType: case MemberType::DurationType:
@@ -583,7 +638,7 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
if (sd.ped_id != 0) { if (sd.ped_id != 0) {
for (int opt=0; opt < numOptions; ++opt) { for (int opt=0; opt < numOptions; ++opt) {
uint64_t const pop_id = getPaymentOptions(opt).pop_id; uint64_t const pop_id = getPaymentOptions(opt).pop_id;
if (pop_id == sd.ped_payment_option_id) { if (pop_id == (uint64_t)sd.ped_payment_option_id) {
return opt; return opt;
} }
} }
@@ -627,7 +682,8 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
} }
} }
return -1; qCritical() << DBG_HEADER << "ERROR: DEFAULT VALUE OF '0' RETURNED AS STATIC VALUE";
return 0;
} }
ATBSpecialDays Configuration::specialDay(QDateTime const &dt) const { ATBSpecialDays Configuration::specialDay(QDateTime const &dt) const {
@@ -718,12 +774,38 @@ Configuration::getTariffProductForAllKeys() const {
} }
std::optional<QVector<ATBTariffProduct>> std::optional<QVector<ATBTariffProduct>>
Configuration::getTariffProductForProductId(PermitType permitType) const { Configuration::getTariffProductForProductTypeName(QString const &permitTypeName) const {
QVector<ATBTariffProduct> products; QVector<ATBTariffProduct> products;
std::optional<QVector<ATBTariffProduct>> value; std::optional<QVector<ATBTariffProduct>> value;
products.clear(); products.clear();
for(const auto &product: this->TariffProduct) {
ATBTariffProduct const &v = product.second;
if (v.m_tariff_product_name == permitTypeName) {
products.append(v);
}
}
if (products.size() > 0) {
value = value.value_or(products);
}
return value;
}
std::optional<QVector<ATBTariffProduct>>
Configuration::getTariffProductForProductId(PermitType permitType) const {
QString permitTypeName(permitType);
return getTariffProductForProductTypeName(permitTypeName);
/*
QVector<ATBTariffProduct> products;
std::optional<QVector<ATBTariffProduct>> value;
products.clear();
for (auto[it, rangeEnd] = this->TariffProduct.equal_range(permitType); it != rangeEnd; ++it) { for (auto[it, rangeEnd] = this->TariffProduct.equal_range(permitType); it != rangeEnd; ++it) {
products.append(it->second); products.append(it->second);
} }
@@ -733,6 +815,7 @@ Configuration::getTariffProductForProductId(PermitType permitType) const {
} }
return value; return value;
*/
} }
std::optional<QVector<ATBTariffProduct>> std::optional<QVector<ATBTariffProduct>>

View File

@@ -334,11 +334,11 @@ QTime Utilities::SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDa
return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_from.c_str(), Qt::ISODate); return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_from.c_str(), Qt::ISODate);
} }
QTime Utilities::SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator it) { QTime Utilities::SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator const &it) {
return QTime::fromString(it->second.pedwt_time_from.c_str(), Qt::ISODate); return QTime::fromString(it->second.pedwt_time_from.c_str(), Qt::ISODate);
} }
QTime Utilities::SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator it) { QTime Utilities::SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator const &it) {
return QTime::fromString(it->second.pedwt_time_to.c_str(), Qt::ISODate); return QTime::fromString(it->second.pedwt_time_to.c_str(), Qt::ISODate);
} }
@@ -346,15 +346,15 @@ QTime Utilities::SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialD
return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_to.c_str(), Qt::ISODate); return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_to.c_str(), Qt::ISODate);
} }
QTime Utilities::WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) { QTime Utilities::WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
return QTime::fromString(itr->second.pwd_time_from.c_str(), Qt::ISODate); return QTime::fromString(itr->second.pwd_time_from.c_str(), Qt::ISODate);
} }
QTime Utilities::WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) { QTime Utilities::WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
return QTime::fromString(itr->second.pwd_time_to.c_str(), Qt::ISODate); return QTime::fromString(itr->second.pwd_time_to.c_str(), Qt::ISODate);
} }
int Utilities::WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) { int Utilities::WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
return itr->second.pwd_period_day_in_week_id; return itr->second.pwd_period_day_in_week_id;
} }
@@ -406,9 +406,16 @@ uint32_t Utilities::getMaximalParkingPrice(Configuration const *cfg, PaymentMeth
return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0); return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0);
} }
uint32_t Utilities::getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId) {
return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_daily_card_price, 0);
}
uint32_t Utilities::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) { uint32_t Utilities::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) {
if (methodId == PaymentMethod::Progressive) { if (methodId == PaymentMethod::Progressive) {
return std::max((int)cfg->TimeRange.find(step)->second.time_range_to_in_minutes_from_start, 0); Configuration::TimeRangeType::const_iterator it = cfg->TimeRange.find(step);
if (it != cfg->TimeRange.cend()) {
return std::max((int)(it->second.time_range_to_in_minutes_from_start), 0);
}
} }
return 0; return 0;

File diff suppressed because it is too large Load Diff