Compare commits
30 Commits
33f43fb83d
...
bad-neuena
Author | SHA1 | Date | |
---|---|---|---|
1d8dfcfa22 | |||
48fccafe76 | |||
9394625d35 | |||
7492e37e02 | |||
f0dca3917c | |||
57ccbc150a | |||
8fa4335669 | |||
49298a1821 | |||
6fb4d245cb | |||
2dc93271fd | |||
5be5798681 | |||
1a24bc4572 | |||
068575f8e8 | |||
e121cef17e | |||
bdaea1106c | |||
bc17213597 | |||
64b2b4bd85 | |||
8737508839 | |||
02f0500eac | |||
2d53224feb | |||
38964ad9a8 | |||
d3f18f3b82 | |||
1a4265372e | |||
eb20410849 | |||
2a492475e3 | |||
6a5272da7a | |||
4d5583df2d | |||
de6f263817 | |||
e4ce14da3f | |||
b71c979a91 |
@@ -42,18 +42,34 @@ struct CALCULATE_LIBRARY_API price_t {
|
||||
};
|
||||
|
||||
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 {
|
||||
SUCCESS,
|
||||
ERROR_PARSING_ZONE_NR,
|
||||
ERROR_LOADING_TARIFF,
|
||||
ERROR_PARSING_TARIFF,
|
||||
NEGATIVE_PARING_TIME,
|
||||
NEGATIVE_PARKING_TIME,
|
||||
INVALID_START_DATE,
|
||||
WRONG_PARAM_VALUES,
|
||||
WRONG_ISO_TIME_FORMAT,
|
||||
ABOVE_MAX_PARKING_TIME,
|
||||
BELOW_MIN_PARKING_TIME,
|
||||
BELOW_MIN_PARKING_PRICE,
|
||||
ABOVE_MAX_PARKING_PRICE,
|
||||
OVERPAID,
|
||||
OUTSIDE_ALLOWED_PARKING_TIME
|
||||
};
|
||||
@@ -88,43 +104,47 @@ struct CALCULATE_LIBRARY_API CalcState {
|
||||
QString s;
|
||||
switch (m_status) {
|
||||
case State::SUCCESS:
|
||||
s = "SUCCESS";
|
||||
s = CalcState::SUCCESS;
|
||||
break;
|
||||
case State::ERROR_PARSING_ZONE_NR:
|
||||
s = "ERROR_PARSING_ZONE_NR";
|
||||
s = CalcState::ERROR_PARSING_ZONE_NR;
|
||||
break;
|
||||
case State::ERROR_LOADING_TARIFF:
|
||||
s = "ERROR_LOADING_TARIFF";
|
||||
s = CalcState::ERROR_LOADING_TARIFF;
|
||||
break;
|
||||
case State::ERROR_PARSING_TARIFF:
|
||||
s = "ERROR_PARSING_TARIFF";
|
||||
s = CalcState::ERROR_PARSING_TARIFF;
|
||||
break;
|
||||
case State::NEGATIVE_PARING_TIME:
|
||||
s = "NEGATIVE_PARKING_TIME";
|
||||
case State::NEGATIVE_PARKING_TIME:
|
||||
s = CalcState::NEGATIVE_PARKING_TIME;
|
||||
break;
|
||||
case State::ABOVE_MAX_PARKING_TIME:
|
||||
s = "ABOVE_MAX_PARKING_TIME";
|
||||
s = CalcState::ABOVE_MAX_PARKING_TIME;
|
||||
break;
|
||||
case State::WRONG_PARAM_VALUES:
|
||||
s = "WRONG_PARAM_VALUES";
|
||||
s = CalcState::WRONG_PARAM_VALUES;
|
||||
break;
|
||||
case State::BELOW_MIN_PARKING_TIME:
|
||||
s = "BELOW_MIN_PARKING_TIME";
|
||||
s = CalcState::BELOW_MIN_PARKING_TIME;
|
||||
break;
|
||||
case State::BELOW_MIN_PARKING_PRICE:
|
||||
s = "BELOW_MIN_PARKING_PRICE";
|
||||
s = CalcState::BELOW_MIN_PARKING_PRICE;
|
||||
break;
|
||||
case State::OVERPAID:
|
||||
s = "OVERPAID";
|
||||
s = CalcState::OVERPAID;
|
||||
break;
|
||||
case State::INVALID_START_DATE:
|
||||
s = "INVALID_START_DATE";
|
||||
s = CalcState::INVALID_START_DATE;
|
||||
break;
|
||||
case State::WRONG_ISO_TIME_FORMAT:
|
||||
s = "WRONG_ISO_TIME_FORMAT";
|
||||
s = CalcState::WRONG_ISO_TIME_FORMAT;
|
||||
break;
|
||||
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;
|
||||
}
|
||||
@@ -133,51 +153,101 @@ struct CALCULATE_LIBRARY_API CalcState {
|
||||
QString s;
|
||||
switch (m_status) {
|
||||
case State::SUCCESS:
|
||||
s = "SUCCESS";
|
||||
s = CalcState::SUCCESS;
|
||||
break;
|
||||
case State::ERROR_PARSING_ZONE_NR:
|
||||
s = "ERROR_PARSING_ZONE_NR";
|
||||
s = CalcState::ERROR_PARSING_ZONE_NR;
|
||||
break;
|
||||
case State::ERROR_LOADING_TARIFF:
|
||||
s = "ERROR_LOADING_TARIFF";
|
||||
s = CalcState::ERROR_LOADING_TARIFF;
|
||||
break;
|
||||
case State::ERROR_PARSING_TARIFF:
|
||||
s = "ERROR_PARSING_TARIFF";
|
||||
s = CalcState::ERROR_PARSING_TARIFF;
|
||||
break;
|
||||
case State::NEGATIVE_PARING_TIME:
|
||||
s = "NEGATIVE_PARKING_TIME";
|
||||
case State::NEGATIVE_PARKING_TIME:
|
||||
s = CalcState::NEGATIVE_PARKING_TIME;
|
||||
break;
|
||||
case State::ABOVE_MAX_PARKING_TIME:
|
||||
s = "ABOVE_MAX_PARKING_TIME";
|
||||
s = CalcState::ABOVE_MAX_PARKING_TIME;
|
||||
break;
|
||||
case State::WRONG_PARAM_VALUES:
|
||||
s = "WRONG_PARAM_VALUES";
|
||||
s = CalcState::WRONG_PARAM_VALUES;
|
||||
break;
|
||||
case State::BELOW_MIN_PARKING_TIME:
|
||||
s = "BELOW_MIN_PARKING_TIME";
|
||||
s = CalcState::BELOW_MIN_PARKING_TIME;
|
||||
break;
|
||||
case State::BELOW_MIN_PARKING_PRICE:
|
||||
s = "BELOW_MIN_PARKING_PRICE";
|
||||
s = CalcState::BELOW_MIN_PARKING_PRICE;
|
||||
break;
|
||||
case State::OVERPAID:
|
||||
s = "OVERPAID";
|
||||
s = CalcState::OVERPAID;
|
||||
break;
|
||||
case State::INVALID_START_DATE:
|
||||
s = "INVALID_START_DATE";
|
||||
s = CalcState::INVALID_START_DATE;
|
||||
break;
|
||||
case State::WRONG_ISO_TIME_FORMAT:
|
||||
s = "WRONG_ISO_TIME_FORMAT";
|
||||
s = CalcState::WRONG_ISO_TIME_FORMAT;
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
CalcState &set(State s) { m_status = s; return *this; }
|
||||
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; }
|
||||
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) {
|
||||
m_allowedTimeRange.setTimeRange(from, until);
|
||||
@@ -207,7 +277,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
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,
|
||||
PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
|
||||
|
@@ -24,6 +24,7 @@ public:
|
||||
pop_min_price = 0;
|
||||
pop_max_price = 0;
|
||||
pop_carry_over = -1;
|
||||
pop_carry_over_target = false;
|
||||
pop_carry_over_time_range_id = -1;
|
||||
pop_carry_over_start_time_range = -1;
|
||||
pop_carry_over_end_time_range = -1;
|
||||
@@ -43,6 +44,7 @@ public:
|
||||
double pop_min_price;
|
||||
double pop_max_price;
|
||||
int pop_carry_over;
|
||||
bool pop_carry_over_target;
|
||||
int pop_carry_over_time_range_id;
|
||||
int pop_carry_over_start_time_range;
|
||||
int pop_carry_over_end_time_range;
|
||||
|
@@ -8,24 +8,28 @@
|
||||
|
||||
#include <Qt>
|
||||
|
||||
#define _NO_RESTRICTION_24_7_ (uint64_t)(0ULL)
|
||||
#define _MON_ (uint64_t)(1ULL << 8)
|
||||
#define _TUE_ (uint64_t)(1ULL << 9)
|
||||
#define _WED_ (uint64_t)(1ULL << 10)
|
||||
#define _THU_ (uint64_t)(1ULL << 11)
|
||||
#define _FRI_ (uint64_t)(1ULL << 12)
|
||||
#define _SAT_ (uint64_t)(1ULL << 13)
|
||||
#define _SUN_ (uint64_t)(1ULL << 14)
|
||||
#define _WEEK_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_))
|
||||
#define _WORKING_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_))
|
||||
#define _ALL_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_|_SUN_))
|
||||
#define _OFFICIAL_HOLIDAY_ (uint64_t)(1ULL << 15)
|
||||
#define _ONLY_WEEKEND_ ((_SAT_|_SUN_))
|
||||
#define _ONLY_OPEN_FOR_BUSINESS_DAYS_ (uint64_t)(1ULL << 16) /* verkaufsoffen */
|
||||
#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 _NOT_DEFINED_ (uint64_t)(~0ULL)
|
||||
#define _NO_RESTRICTION_24_7_ (uint64_t)(0ULL)
|
||||
#define _MON_ (uint64_t)(1ULL << 8)
|
||||
#define _TUE_ (uint64_t)(1ULL << 9)
|
||||
#define _WED_ (uint64_t)(1ULL << 10)
|
||||
#define _THU_ (uint64_t)(1ULL << 11)
|
||||
#define _FRI_ (uint64_t)(1ULL << 12)
|
||||
#define _SAT_ (uint64_t)(1ULL << 13)
|
||||
#define _SUN_ (uint64_t)(1ULL << 14)
|
||||
#define _WEEK_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_))
|
||||
#define _WORKING_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_))
|
||||
#define _ALL_DAYS_ ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_|_SUN_))
|
||||
#define _OFFICIAL_HOLIDAY_ (uint64_t)(1ULL << 15)
|
||||
#define _ONLY_WEEKEND_ ((_SAT_|_SUN_))
|
||||
#define _ONLY_OPEN_FOR_BUSINESS_DAYS_ (uint64_t)(1ULL << 16) /* verkaufsoffen */
|
||||
#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
|
||||
{
|
||||
@@ -59,6 +63,10 @@ enum BusinessHours : std::uint64_t
|
||||
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_
|
||||
};
|
||||
|
||||
|
@@ -79,12 +79,12 @@ namespace Utilities {
|
||||
double CalculatePricePerUnit(double pra_price, double durationUnit = -1);
|
||||
|
||||
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::SpecialDaysWorktimeType::const_iterator it);
|
||||
QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
|
||||
QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
|
||||
int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
|
||||
QTime SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator const &it);
|
||||
QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
|
||||
QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
|
||||
int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
|
||||
// PaymentRate GetPaymentRate(Configuration const *cfg, );
|
||||
bool isCarryOverSet(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);
|
||||
double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
|
||||
QStringList dumpBusinessHours(uint64_t businessHours);
|
||||
uint32_t getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId);
|
||||
}
|
||||
|
@@ -12,6 +12,10 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/include/rapidjson
|
||||
#Version is set in yocto recipe with "EXTRA_QMAKEVARS_PRE"
|
||||
#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) {
|
||||
win32 {
|
||||
QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS
|
||||
|
@@ -10,6 +10,21 @@
|
||||
#include <QDebug>
|
||||
#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) {
|
||||
return Calculator::GetInstance().GetTimeSteps(cfg);
|
||||
}
|
||||
@@ -21,6 +36,8 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
||||
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
QList<int> const tsteps = Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
|
||||
Q_UNUSED(tsteps);
|
||||
minTime = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
||||
@@ -64,7 +81,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
PERMIT_TYPE permitType,
|
||||
int paymentOptionIndex) {
|
||||
int paymentOptionIndex,
|
||||
QDateTime const &start) {
|
||||
int minPrice = -1;
|
||||
|
||||
switch(permitType) {
|
||||
@@ -77,6 +95,9 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET: {
|
||||
minPrice = compute_product_price(cfg, permitType, start);
|
||||
} break;
|
||||
default: ;
|
||||
}
|
||||
|
||||
@@ -145,6 +166,10 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
||||
QTime const &startTime = p.getTimeStart();
|
||||
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) {
|
||||
product_price = p.getProductPrice();
|
||||
if (productStart && productEnd) {
|
||||
@@ -155,6 +180,17 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
||||
}
|
||||
|
||||
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;
|
||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
|
||||
@@ -419,7 +455,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
if (duration < 0) {
|
||||
calcState.setDesc(QString("end=%1, start=%2")
|
||||
.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) {
|
||||
calcState.setDesc(QString("duration=%1, maxMin=%2").arg(duration).arg(maxMin));
|
||||
@@ -476,6 +512,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "compute_price_for_parking_ticket() " << endl
|
||||
<< " paymentOptionIndex: " << paymentOptionIndex << endl
|
||||
<< " start_parking_time: " << start_parking_time << endl
|
||||
<< " netto_parking_time: " << netto_parking_time << endl
|
||||
<< " minMin: " << minMin << endl
|
||||
@@ -486,7 +523,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
calcState.setDesc(QString("end=%1, start=%2")
|
||||
.arg(end_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) {
|
||||
calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin));
|
||||
@@ -502,15 +539,21 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
|
||||
double cost = -1;
|
||||
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?
|
||||
calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time,
|
||||
netto_parking_time, paymentOptionIndex);
|
||||
if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
// << calcState.toString();
|
||||
return calcState;
|
||||
}
|
||||
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 {
|
||||
cost = Calculator::GetInstance().GetCostFromDuration(
|
||||
tariff,
|
||||
@@ -527,7 +570,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
}
|
||||
|
||||
// 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->units = cost;
|
||||
@@ -588,16 +632,76 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
cs.toLocal8Bit().constData(),
|
||||
price, false, true).c_str();
|
||||
ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "compute_duration_for_parking_ticket(): ";
|
||||
qCritical() << " endTime: " << endTime;
|
||||
qCritical() << " ticketEndTime: " << ticketEndTime;
|
||||
if (endTime == CalcState::SUCCESS) {
|
||||
calcState.setDesc(QString("SUCCESS"));
|
||||
calcState.setStatus(endTime);
|
||||
} 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()) {
|
||||
calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
|
||||
return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
|
||||
// DEBUG
|
||||
//qCritical() << "compute_duration_for_parking_ticket(): ";
|
||||
//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 {
|
||||
return calcState.set(CalcState::State::INVALID_START_DATE);
|
||||
|
@@ -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 "";
|
||||
}
|
||||
}
|
||||
@@ -628,12 +849,19 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
|
||||
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
if (paymentMethodId == PaymentMethod::Steps) {
|
||||
uint64_t const businessHours = cfg->getPaymentOptions(paymentOptionIndex).pop_business_hours;
|
||||
|
||||
if (cfg->isDayIncluded(businessHours, start)) {
|
||||
if (businessHours == BusinessHours::NO_RESTRICTION_24_7) {
|
||||
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
|
||||
QTime(0, 0, 0), QTime(23, 59, 59));
|
||||
}
|
||||
|
||||
int const weekdayId = start.date().dayOfWeek();
|
||||
|
||||
// qCritical() << DBG_HEADER
|
||||
// << "weekdayId" << weekdayId
|
||||
// << "count" << cfg->WeekDaysWorktime.count(weekdayId);
|
||||
|
||||
if (cfg->WeekDaysWorktime.count(weekdayId) > 0) {
|
||||
using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
|
||||
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();
|
||||
|
||||
if (startTime >= from && startTime <= until) {
|
||||
QTime const endTime = start.addSecs(netto_parking_time*60).time();
|
||||
if (endTime <= until) {
|
||||
QDateTime const end = start.addSecs(netto_parking_time*60);
|
||||
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);
|
||||
} else {
|
||||
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;
|
||||
|
||||
// qCritical() << DBG_HEADER
|
||||
// << "paymentOptionIndex" << paymentOptionIndex
|
||||
// << "pop_carry_over" << pop_carry_over;
|
||||
|
||||
if (pop_carry_over == 1) {
|
||||
qCritical() << DBG_HEADER
|
||||
<< "NO. CHECK IF PARKING IS ALLOWED WITH CARRY-OVER ...";
|
||||
// qCritical() << DBG_HEADER
|
||||
// << "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_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 &&
|
||||
cfg->TimeRange.count(pop_carry_over_end_time_range) == 1) {
|
||||
|
||||
ATBTimeRange s = cfg->TimeRange.find(pop_carry_over_start_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()) {
|
||||
|
||||
QDateTime sd = start;
|
||||
sd.setTime(s.getTimeUntil());
|
||||
|
||||
// qCritical() << DBG_HEADER << "jumpFrom" << sd.toString(Qt::ISODate);
|
||||
|
||||
QDateTime ed = start.addDays(1);
|
||||
ed.setTime(e.getTimeFrom());
|
||||
|
||||
// qCritical() << DBG_HEADER << "to" << ed.toString(Qt::ISODate);
|
||||
|
||||
int const jumpSecs = sd.secsTo(ed);
|
||||
|
||||
// qCritical() << DBG_HEADER << "jumpSecs" << 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()) {
|
||||
|
||||
qCritical() << DBG_HEADER
|
||||
@@ -699,13 +960,13 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
|
||||
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
|
||||
startTime, end.time());
|
||||
} else {
|
||||
errorStr = QString("endTime %1 exceeds [%2, %3))")
|
||||
errorStr = QString("endTime %1 outside [%2, %3))")
|
||||
.arg(end.toString(Qt::ISODate))
|
||||
.arg(sd.toString(Qt::ISODate))
|
||||
.arg(ed.toString(Qt::ISODate));
|
||||
}
|
||||
} else {
|
||||
errorStr = QString("startTime %1 exceeds [%2, %3))")
|
||||
errorStr = QString("startTime %1 outside [%2, %3))")
|
||||
.arg(startTime.toString(Qt::ISODate))
|
||||
.arg(s.getTimeFrom().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,
|
||||
QTime(), QTime());
|
||||
}
|
||||
@@ -2005,6 +2268,9 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
|
||||
if (dailyTickets) {
|
||||
QVector<ATBDailyTicket> const tickets = dailyTickets.value();
|
||||
switch (permitType) {
|
||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
|
||||
// TODO
|
||||
} break;
|
||||
case PERMIT_TYPE::FOOD_STAMP: {
|
||||
// TODO
|
||||
} break;
|
||||
|
@@ -478,21 +478,19 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "DAY" << dt.day;
|
||||
qCritical() << "DIR" << dt.direction;
|
||||
qCritical() << "week" << dt.week;
|
||||
qCritical() << "DIR" << dt.time;
|
||||
|
||||
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;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
case MemberType::DurationType:
|
||||
@@ -684,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 {
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -406,6 +406,10 @@ uint32_t Utilities::getMaximalParkingPrice(Configuration const *cfg, PaymentMeth
|
||||
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) {
|
||||
if (methodId == PaymentMethod::Progressive) {
|
||||
Configuration::TimeRangeType::const_iterator it = cfg->TimeRange.find(step);
|
||||
|
807
main/main.cpp
807
main/main.cpp
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user