diff --git a/library/include/mobilisis/calculate_price.h b/library/include/mobilisis/calculate_price.h
index aa6daba..ee5f1e9 100644
--- a/library/include/mobilisis/calculate_price.h
+++ b/library/include/mobilisis/calculate_price.h
@@ -56,6 +56,7 @@ struct CALCULATE_LIBRARY_API CalcState {
static QString const ABOVE_MAX_PARKING_PRICE;
static QString const OVERPAID;
static QString const OUTSIDE_ALLOWED_PARKING_TIME;
+ static QString const SUCCESS_MAXPRICE;
enum class State : uint8_t {
SUCCESS,
@@ -71,7 +72,8 @@ struct CALCULATE_LIBRARY_API CalcState {
BELOW_MIN_PARKING_PRICE,
ABOVE_MAX_PARKING_PRICE,
OVERPAID,
- OUTSIDE_ALLOWED_PARKING_TIME
+ OUTSIDE_ALLOWED_PARKING_TIME,
+ SUCCESS_MAXPRICE
};
State m_status;
@@ -106,6 +108,9 @@ struct CALCULATE_LIBRARY_API CalcState {
case State::SUCCESS:
s = CalcState::SUCCESS;
break;
+ case State::SUCCESS_MAXPRICE:
+ s = CalcState::SUCCESS_MAXPRICE;
+ break;
case State::ERROR_PARSING_ZONE_NR:
s = CalcState::ERROR_PARSING_ZONE_NR;
break;
@@ -158,6 +163,9 @@ struct CALCULATE_LIBRARY_API CalcState {
case State::SUCCESS:
s = CalcState::SUCCESS;
break;
+ case State::SUCCESS_MAXPRICE:
+ s = CalcState::SUCCESS_MAXPRICE;
+ break;
case State::ERROR_PARSING_ZONE_NR:
s = CalcState::ERROR_PARSING_ZONE_NR;
break;
@@ -207,6 +215,9 @@ struct CALCULATE_LIBRARY_API CalcState {
if (desc == SUCCESS) {
m_status = State::SUCCESS;
} else
+ if (desc == SUCCESS_MAXPRICE) {
+ m_status = State::SUCCESS_MAXPRICE;
+ }
if (desc == ERROR_PARSING_ZONE_NR) {
m_status = State::ERROR_PARSING_ZONE_NR;
} else
diff --git a/library/include/mobilisis/calculator_functions.h b/library/include/mobilisis/calculator_functions.h
index 0e22b66..7aeb2b8 100644
--- a/library/include/mobilisis/calculator_functions.h
+++ b/library/include/mobilisis/calculator_functions.h
@@ -73,7 +73,7 @@ public:
/// Returns duration in seconds (data type: double)
std::pair
GetDurationFromCost(Configuration* cfg, uint8_t vehicle_type, char const* start_datetime, double price,
- PermitType permitType, bool nextDay = false, bool prepaid = false);
+ PermitType permitType, bool nextDay = false, bool prepaid = false);
///
/// Gets cost from duration in seconds
diff --git a/library/src/calculate_price.cpp b/library/src/calculate_price.cpp
index fbacfb9..1a5e06f 100644
--- a/library/src/calculate_price.cpp
+++ b/library/src/calculate_price.cpp
@@ -26,6 +26,7 @@ QString const CalcState::BELOW_MIN_PARKING_PRICE = "BELOW_MIN_PARKING_PRICE";
QString const CalcState::ABOVE_MAX_PARKING_PRICE = "ABOVE_MAX_PARKING_PRICE";
QString const CalcState::OVERPAID = "OVERPAID";
QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME";
+QString const CalcState::SUCCESS_MAXPRICE = "SUCCESS_MAXPRICE";
QList CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
return Calculator::GetInstance().GetTimeSteps(cfg);
@@ -818,6 +819,13 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
qCritical() << __func__ << ":" << __LINE__ << " re-computed prepaid-id" << pop_prepaid_option_id;
}
+ QTime carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
+ int carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
+
+ qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
+ qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration" << carryOverDuration;
+
+
QDateTime effectiveStartTime(start_parking_time);
// handle special days
@@ -885,7 +893,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
// handle carry over
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
- if (netto_parking_time > minutesUntilCarryOver) {
+ if ((minutesUntilCarryOver > 0) && (netto_parking_time > minutesUntilCarryOver)) {
int const rest = netto_parking_time - minutesUntilCarryOver;
QDateTime s(effectiveStartTime);
s = s.addSecs(minutesUntilCarryOver * 60);
@@ -1207,6 +1215,15 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
if (ticketEndTime.time() > carryOverStart) {
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
+ } else
+ if (ticketEndTime.time() == carryOverStart) {
+ qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
+ qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
+ ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
+ if (po.pop_apply_carry_over_to_ticket_endtime) {
+ ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
+ qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
+ }
} else {
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
if (ticketEndTime.time() < carryOverEnd) {
diff --git a/library/src/calculator_functions.cpp b/library/src/calculator_functions.cpp
index 22a26f8..aa1e58e 100644
--- a/library/src/calculator_functions.cpp
+++ b/library/src/calculator_functions.cpp
@@ -136,6 +136,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
bool overPaid = false;
+ bool successMaxPrice = false; // max-price and cost match
int paymentOptionIndex = getPaymentOptionIndex(*cfg, inputDate);
if (paymentOptionIndex == -1) {
@@ -273,6 +274,11 @@ Calculator::GetDurationFromCost(Configuration* cfg,
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
+ if (cost == pop_max_price) {
+ qCritical() << DBG_HEADER << "SUCCESS MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
+ successMaxPrice = true;
+ }
+
if (cost > pop_max_price) {
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
if (pop_allow_overpay == false) {
@@ -280,6 +286,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
}
cost = pop_max_price;
overPaid = true;
+ qCritical() << DBG_HEADER << "OVERPAID, MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
// return CalcState::OVERPAID.toStdString();
}
@@ -447,6 +454,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), d);
}
+ if (successMaxPrice) {
+ return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), d);
+ }
return std::make_pair(d.toString(Qt::ISODate).toStdString(), d);
}
} else {
@@ -561,6 +571,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), inputDate);
}
+ if (successMaxPrice) {
+ return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), inputDate);
+ }
return std::make_pair(s.toStdString(), inputDate);
} // if ((double)price == cost) {
else {
@@ -648,6 +661,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
+ if (successMaxPrice) {
+ return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
+ }
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
} else {
QDateTime const dt = start;
@@ -698,6 +714,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
+ if (successMaxPrice) {
+ return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
+ }
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
@@ -796,6 +815,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
+ if (successMaxPrice) {
+ return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
+ }
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
}
@@ -840,6 +862,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
+ if (successMaxPrice) {
+ return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
+ }
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
@@ -874,6 +899,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
+ if (successMaxPrice) {
+ return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
+ }
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
@@ -993,6 +1021,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
+ if (successMaxPrice) {
+ return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
+ }
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
}
diff --git a/main/main.pro b/main/main.pro
index 37cd791..438e946 100644
--- a/main/main.pro
+++ b/main/main.pro
@@ -34,7 +34,11 @@ OTHER_FILES += \
/opt/ptu5/opt/customer_335/etc/psa_tariff/tariff02.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json \
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json \
- /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json
+ /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json \
+ /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff04.json \
+ /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff05.json \
+ /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff06.json \
+ /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff07.json