Compare commits
5 Commits
35294e99f0
...
master
Author | SHA1 | Date | |
---|---|---|---|
f2156e4650
|
|||
338a1a4ebc
|
|||
b4818a3918 | |||
78cae24389 | |||
de0be1d19b |
@@ -43,13 +43,24 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
|||||||
int paymentOptionIndex) {
|
int paymentOptionIndex) {
|
||||||
int minTime = 0;
|
int minTime = 0;
|
||||||
|
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
Configuration *c = tariffs[permitType].get();
|
||||||
|
if (c && c != cfg) {
|
||||||
|
cfg = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
paymentOptionIndex = getPaymentOptionIndex(*cfg);
|
paymentOptionIndex = getPaymentOptionIndex(*cfg);
|
||||||
if (paymentOptionIndex == -1) {
|
if (paymentOptionIndex == -1) {
|
||||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
}
|
}
|
||||||
|
|
||||||
qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
||||||
qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString();
|
qCritical() << __func__ << __LINE__ << "permit" << (int)permitType << PermitType(permitType).toString();
|
||||||
|
qCritical() << __func__ << __LINE__ << "min_time" << (int)permitType << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
|
qCritical() << __func__ << __LINE__ << "min_price" << (int)permitType << cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||||
|
|
||||||
switch(permitType) {
|
switch(permitType) {
|
||||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||||
@@ -79,6 +90,15 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
|||||||
PERMIT_TYPE permitType,
|
PERMIT_TYPE permitType,
|
||||||
int paymentOptionIndex) {
|
int paymentOptionIndex) {
|
||||||
|
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
Configuration *c = tariffs[permitType].get();
|
||||||
|
if (c && c != cfg) {
|
||||||
|
cfg = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
paymentOptionIndex = getPaymentOptionIndex(*cfg);
|
paymentOptionIndex = getPaymentOptionIndex(*cfg);
|
||||||
if (paymentOptionIndex == -1) {
|
if (paymentOptionIndex == -1) {
|
||||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
@@ -109,6 +129,15 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
|||||||
QDateTime const &start) {
|
QDateTime const &start) {
|
||||||
int minPrice = -1;
|
int minPrice = -1;
|
||||||
|
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
Configuration *c = tariffs[permitType].get();
|
||||||
|
if (c && c != cfg) {
|
||||||
|
cfg = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((paymentOptionIndex = getPaymentOptionIndex(*cfg, start)) == -1) {
|
if ((paymentOptionIndex = getPaymentOptionIndex(*cfg, start)) == -1) {
|
||||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
}
|
}
|
||||||
@@ -173,6 +202,14 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
|||||||
QDateTime const &start,
|
QDateTime const &start,
|
||||||
QDateTime *productStart,
|
QDateTime *productStart,
|
||||||
QDateTime *productEnd) {
|
QDateTime *productEnd) {
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
Configuration *c = tariffs[permitType].get();
|
||||||
|
if (c && c != cfg) {
|
||||||
|
cfg = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch(permitType) {
|
switch(permitType) {
|
||||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||||
@@ -336,6 +373,16 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
|||||||
PERMIT_TYPE permitType,
|
PERMIT_TYPE permitType,
|
||||||
int paymentOptionIndex) {
|
int paymentOptionIndex) {
|
||||||
int maxPrice = -1;
|
int maxPrice = -1;
|
||||||
|
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
Configuration *c = tariffs[permitType].get();
|
||||||
|
if (c && c != cfg) {
|
||||||
|
cfg = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
|
||||||
if ((paymentOptionIndex = getPaymentOptionIndex(*cfg)) == -1) {
|
if ((paymentOptionIndex = getPaymentOptionIndex(*cfg)) == -1) {
|
||||||
@@ -724,6 +771,15 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
start = start.toLocalTime().addSecs(start_parking_time * 60);
|
start = start.toLocalTime().addSecs(start_parking_time * 60);
|
||||||
QDateTime end(start);
|
QDateTime end(start);
|
||||||
|
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
parking_tariff_t *t = tariffs[permitType].get();
|
||||||
|
if (t && t != tariff) {
|
||||||
|
tariff = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int paymentOptionIndex = getPaymentOptionIndex(*tariff, start);
|
int paymentOptionIndex = getPaymentOptionIndex(*tariff, start);
|
||||||
if (paymentOptionIndex == -1) {
|
if (paymentOptionIndex == -1) {
|
||||||
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
|
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
|
||||||
@@ -799,6 +855,15 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
|
|
||||||
QDateTime start_parking_time(start_parking_time_);
|
QDateTime start_parking_time(start_parking_time_);
|
||||||
|
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
parking_tariff_t *t = tariffs[permitType].get();
|
||||||
|
if (t && t != tariff) {
|
||||||
|
tariff = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
|
int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
|
||||||
if (paymentOptionIndex == -1) {
|
if (paymentOptionIndex == -1) {
|
||||||
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||||
@@ -881,6 +946,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
|
|
||||||
|
|
||||||
QDateTime effectiveStartTime(start_parking_time);
|
QDateTime effectiveStartTime(start_parking_time);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
|
||||||
|
<< effectiveStartTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
// handle special days
|
// handle special days
|
||||||
int const specialDayId = tariff->specialDayId(start_parking_time);
|
int const specialDayId = tariff->specialDayId(start_parking_time);
|
||||||
@@ -911,6 +978,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
|
||||||
|
<< effectiveStartTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
// handle prepaid option
|
// handle prepaid option
|
||||||
int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||||
std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
|
std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
|
||||||
@@ -925,17 +995,36 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
|
|
||||||
if (start_parking_time.time() < p.prepaid[weekDay].static_end) { // static_end: e.g. 08:00:00
|
if (start_parking_time.time() < p.prepaid[weekDay].static_end) { // static_end: e.g. 08:00:00
|
||||||
effectiveStartTime.setTime(p.prepaid[weekDay].static_end);
|
effectiveStartTime.setTime(p.prepaid[weekDay].static_end);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
|
||||||
|
<< effectiveStartTime.toString(Qt::ISODate);
|
||||||
} else
|
} else
|
||||||
if (start_parking_time.time() > p.prepaid[weekDay].static_start) { // static_start: e.g. 22:00:00
|
if (start_parking_time.time() > p.prepaid[weekDay].static_start) { // static_start: e.g. 22:00:00
|
||||||
effectiveStartTime.setTime(p.prepaid[weekDay].static_start);
|
QTime const midnight(23, 59, 59);
|
||||||
|
QTime const midnight24(0, 0, 0);
|
||||||
|
|
||||||
|
if ((p.prepaid[weekDay].static_start <= midnight && midnight24 <= p.prepaid[weekDay].static_end)
|
||||||
|
|| (p.prepaid[weekDay].static_start == midnight && midnight == p.prepaid[weekDay].static_end)
|
||||||
|
|| (p.prepaid[weekDay].static_start == midnight24 && midnight24 == p.prepaid[weekDay].static_end)) {
|
||||||
|
effectiveStartTime = effectiveStartTime.addDays(1);
|
||||||
|
weekDay = effectiveStartTime.date().dayOfWeek();
|
||||||
|
qCritical() << __func__ << ":" << __LINE__
|
||||||
|
<< "effectiveStartTime: new week day [" << weekDay << "] (Mon=1, Tue=2, ..., Sun=7)";
|
||||||
|
}
|
||||||
|
effectiveStartTime.setTime(p.prepaid[weekDay].static_end);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
|
||||||
|
<< effectiveStartTime.toString(Qt::ISODate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "no prepaid option set";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set seconds to 0
|
||||||
effectiveStartTime.setTime(QTime(effectiveStartTime.time().hour(),
|
effectiveStartTime.setTime(QTime(effectiveStartTime.time().hour(),
|
||||||
effectiveStartTime.time().minute(), 0));
|
effectiveStartTime.time().minute(), 0));
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:" << effectiveStartTime.toString(Qt::ISODate);
|
qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
|
||||||
|
<< effectiveStartTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
int const carryOver = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
int const carryOver = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||||
|
|
||||||
@@ -958,12 +1047,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
s = s.addSecs(minutesUntilCarryOver * 60);
|
s = s.addSecs(minutesUntilCarryOver * 60);
|
||||||
s = s.addSecs(carryOverDuration * 60);
|
s = s.addSecs(carryOverDuration * 60);
|
||||||
end_parking_time = s.addSecs(rest * 60);
|
end_parking_time = s.addSecs(rest * 60);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
|
||||||
} else {
|
} else {
|
||||||
end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
|
end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
|
||||||
}
|
}
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
|
|
||||||
|
|
||||||
weekDay = end_parking_time.date().dayOfWeek();
|
weekDay = end_parking_time.date().dayOfWeek();
|
||||||
|
|
||||||
// musste man in einer schleife machen
|
// musste man in einer schleife machen
|
||||||
@@ -1077,6 +1166,15 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
QString &duration,
|
QString &duration,
|
||||||
PermitType permitType) {
|
PermitType permitType) {
|
||||||
|
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
parking_tariff_t *t = tariffs[permitType].get();
|
||||||
|
if (t && t != tariff) {
|
||||||
|
tariff = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tariff->getPaymentOptions(0).pop_max_price
|
tariff->getPaymentOptions(0).pop_max_price
|
||||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||||
|
|
||||||
@@ -1135,8 +1233,13 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
QDateTime &ticketEndTime,
|
QDateTime &ticketEndTime,
|
||||||
PermitType permitType)
|
PermitType permitType)
|
||||||
{
|
{
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
if (tariffs.count(permitType) > 0) {
|
if (tariffs.count(permitType) > 0) {
|
||||||
tariff = tariffs[permitType].get();
|
parking_tariff_t *t = tariffs[permitType].get();
|
||||||
|
if (t && t != tariff) {
|
||||||
|
tariff = t;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tariff->getPaymentOptions(0).pop_max_price
|
tariff->getPaymentOptions(0).pop_max_price
|
||||||
@@ -1474,8 +1577,17 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,
|
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,
|
||||||
QDateTime const &start_parking_time,
|
QDateTime const &start_parking_time,
|
||||||
QDateTime &ticketEndTime,
|
QDateTime &ticketEndTime,
|
||||||
PermitType /* PermitType */)
|
PermitType permitType)
|
||||||
{
|
{
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
parking_tariff_t *t = tariffs[permitType].get();
|
||||||
|
if (t && t != tariff) {
|
||||||
|
tariff = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tariff->getPaymentOptions(0).pop_max_price
|
tariff->getPaymentOptions(0).pop_max_price
|
||||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||||
|
|
||||||
@@ -1511,6 +1623,15 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_daily_ticket(
|
|||||||
PERMIT_TYPE permitType,
|
PERMIT_TYPE permitType,
|
||||||
struct price_t *price) {// return value
|
struct price_t *price) {// return value
|
||||||
|
|
||||||
|
// tariffs are only set if there is a Includes-section in the tariff-file,
|
||||||
|
// which means the code below will be executed only in such a case.
|
||||||
|
if (tariffs.count(permitType) > 0) {
|
||||||
|
parking_tariff_t *t = tariffs[permitType].get();
|
||||||
|
if (t && t != tariff) {
|
||||||
|
tariff = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tariff->getPaymentOptions(0).pop_max_price
|
tariff->getPaymentOptions(0).pop_max_price
|
||||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user