Cimmit to compile and test.
This commit is contained in:
parent
1874b08210
commit
0b42406b0f
@ -56,6 +56,7 @@ struct CALCULATE_LIBRARY_API CalcState {
|
|||||||
static QString const ABOVE_MAX_PARKING_PRICE;
|
static QString const ABOVE_MAX_PARKING_PRICE;
|
||||||
static QString const OVERPAID;
|
static QString const OVERPAID;
|
||||||
static QString const OUTSIDE_ALLOWED_PARKING_TIME;
|
static QString const OUTSIDE_ALLOWED_PARKING_TIME;
|
||||||
|
static QString const SUCCESS_MAXPRICE;
|
||||||
|
|
||||||
enum class State : uint8_t {
|
enum class State : uint8_t {
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
@ -71,7 +72,8 @@ struct CALCULATE_LIBRARY_API CalcState {
|
|||||||
BELOW_MIN_PARKING_PRICE,
|
BELOW_MIN_PARKING_PRICE,
|
||||||
ABOVE_MAX_PARKING_PRICE,
|
ABOVE_MAX_PARKING_PRICE,
|
||||||
OVERPAID,
|
OVERPAID,
|
||||||
OUTSIDE_ALLOWED_PARKING_TIME
|
OUTSIDE_ALLOWED_PARKING_TIME,
|
||||||
|
SUCCESS_MAXPRICE
|
||||||
};
|
};
|
||||||
|
|
||||||
State m_status;
|
State m_status;
|
||||||
@ -106,6 +108,9 @@ struct CALCULATE_LIBRARY_API CalcState {
|
|||||||
case State::SUCCESS:
|
case State::SUCCESS:
|
||||||
s = CalcState::SUCCESS;
|
s = CalcState::SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
case State::SUCCESS_MAXPRICE:
|
||||||
|
s = CalcState::SUCCESS_MAXPRICE;
|
||||||
|
break;
|
||||||
case State::ERROR_PARSING_ZONE_NR:
|
case State::ERROR_PARSING_ZONE_NR:
|
||||||
s = CalcState::ERROR_PARSING_ZONE_NR;
|
s = CalcState::ERROR_PARSING_ZONE_NR;
|
||||||
break;
|
break;
|
||||||
@ -158,6 +163,9 @@ struct CALCULATE_LIBRARY_API CalcState {
|
|||||||
case State::SUCCESS:
|
case State::SUCCESS:
|
||||||
s = CalcState::SUCCESS;
|
s = CalcState::SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
case State::SUCCESS_MAXPRICE:
|
||||||
|
s = CalcState::SUCCESS_MAXPRICE;
|
||||||
|
break;
|
||||||
case State::ERROR_PARSING_ZONE_NR:
|
case State::ERROR_PARSING_ZONE_NR:
|
||||||
s = CalcState::ERROR_PARSING_ZONE_NR;
|
s = CalcState::ERROR_PARSING_ZONE_NR;
|
||||||
break;
|
break;
|
||||||
@ -207,6 +215,9 @@ struct CALCULATE_LIBRARY_API CalcState {
|
|||||||
if (desc == SUCCESS) {
|
if (desc == SUCCESS) {
|
||||||
m_status = State::SUCCESS;
|
m_status = State::SUCCESS;
|
||||||
} else
|
} else
|
||||||
|
if (desc == SUCCESS_MAXPRICE) {
|
||||||
|
m_status = State::SUCCESS_MAXPRICE;
|
||||||
|
}
|
||||||
if (desc == ERROR_PARSING_ZONE_NR) {
|
if (desc == ERROR_PARSING_ZONE_NR) {
|
||||||
m_status = State::ERROR_PARSING_ZONE_NR;
|
m_status = State::ERROR_PARSING_ZONE_NR;
|
||||||
} else
|
} else
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
/// <returns>Returns duration in seconds (data type: double)</returns>
|
/// <returns>Returns duration in seconds (data type: double)</returns>
|
||||||
std::pair<std::string, QDateTime>
|
std::pair<std::string, QDateTime>
|
||||||
GetDurationFromCost(Configuration* cfg, uint8_t vehicle_type, char const* start_datetime, double price,
|
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);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets cost from duration in seconds
|
/// Gets cost from duration in seconds
|
||||||
|
@ -26,6 +26,7 @@ QString const CalcState::BELOW_MIN_PARKING_PRICE = "BELOW_MIN_PARKING_PRICE";
|
|||||||
QString const CalcState::ABOVE_MAX_PARKING_PRICE = "ABOVE_MAX_PARKING_PRICE";
|
QString const CalcState::ABOVE_MAX_PARKING_PRICE = "ABOVE_MAX_PARKING_PRICE";
|
||||||
QString const CalcState::OVERPAID = "OVERPAID";
|
QString const CalcState::OVERPAID = "OVERPAID";
|
||||||
QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME";
|
QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME";
|
||||||
|
QString const CalcState::SUCCESS_MAXPRICE = "SUCCESS_MAXPRICE";
|
||||||
|
|
||||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
|
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
|
||||||
return Calculator::GetInstance().GetTimeSteps(cfg);
|
return Calculator::GetInstance().GetTimeSteps(cfg);
|
||||||
@ -818,6 +819,13 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
qCritical() << __func__ << ":" << __LINE__ << " re-computed prepaid-id" << pop_prepaid_option_id;
|
qCritical() << __func__ << ":" << __LINE__ << " re-computed prepaid-id" << pop_prepaid_option_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTime carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
|
||||||
|
int carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration" << carryOverDuration;
|
||||||
|
|
||||||
|
|
||||||
QDateTime effectiveStartTime(start_parking_time);
|
QDateTime effectiveStartTime(start_parking_time);
|
||||||
|
|
||||||
// handle special days
|
// handle special days
|
||||||
@ -885,7 +893,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
|
|
||||||
// handle carry over
|
// handle carry over
|
||||||
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
|
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
|
||||||
if (netto_parking_time > minutesUntilCarryOver) {
|
if ((minutesUntilCarryOver > 0) && (netto_parking_time > minutesUntilCarryOver)) {
|
||||||
int const rest = netto_parking_time - minutesUntilCarryOver;
|
int const rest = netto_parking_time - minutesUntilCarryOver;
|
||||||
QDateTime s(effectiveStartTime);
|
QDateTime s(effectiveStartTime);
|
||||||
s = s.addSecs(minutesUntilCarryOver * 60);
|
s = s.addSecs(minutesUntilCarryOver * 60);
|
||||||
@ -1207,6 +1215,15 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
if (ticketEndTime.time() > carryOverStart) {
|
if (ticketEndTime.time() > carryOverStart) {
|
||||||
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
||||||
|
} else
|
||||||
|
if (ticketEndTime.time() == carryOverStart) {
|
||||||
|
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||||
|
ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
|
||||||
|
if (po.pop_apply_carry_over_to_ticket_endtime) {
|
||||||
|
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
||||||
|
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
if (ticketEndTime.time() < carryOverEnd) {
|
if (ticketEndTime.time() < carryOverEnd) {
|
||||||
|
@ -136,6 +136,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
|
||||||
bool overPaid = false;
|
bool overPaid = false;
|
||||||
|
bool successMaxPrice = false; // max-price and cost match
|
||||||
|
|
||||||
int paymentOptionIndex = getPaymentOptionIndex(*cfg, inputDate);
|
int paymentOptionIndex = getPaymentOptionIndex(*cfg, inputDate);
|
||||||
if (paymentOptionIndex == -1) {
|
if (paymentOptionIndex == -1) {
|
||||||
@ -273,6 +274,11 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||||
int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
|
int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
|
||||||
|
|
||||||
|
if (cost == pop_max_price) {
|
||||||
|
qCritical() << DBG_HEADER << "SUCCESS MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
|
||||||
|
successMaxPrice = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (cost > pop_max_price) {
|
if (cost > pop_max_price) {
|
||||||
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
|
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
|
||||||
if (pop_allow_overpay == false) {
|
if (pop_allow_overpay == false) {
|
||||||
@ -280,6 +286,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
}
|
}
|
||||||
cost = pop_max_price;
|
cost = pop_max_price;
|
||||||
overPaid = true;
|
overPaid = true;
|
||||||
|
qCritical() << DBG_HEADER << "OVERPAID, MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
|
||||||
// return CalcState::OVERPAID.toStdString();
|
// return CalcState::OVERPAID.toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,6 +454,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
if (overPaid) {
|
if (overPaid) {
|
||||||
return std::make_pair(CalcState::OVERPAID.toStdString(), d);
|
return std::make_pair(CalcState::OVERPAID.toStdString(), d);
|
||||||
}
|
}
|
||||||
|
if (successMaxPrice) {
|
||||||
|
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), d);
|
||||||
|
}
|
||||||
return std::make_pair(d.toString(Qt::ISODate).toStdString(), d);
|
return std::make_pair(d.toString(Qt::ISODate).toStdString(), d);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -561,6 +571,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
if (overPaid) {
|
if (overPaid) {
|
||||||
return std::make_pair(CalcState::OVERPAID.toStdString(), inputDate);
|
return std::make_pair(CalcState::OVERPAID.toStdString(), inputDate);
|
||||||
}
|
}
|
||||||
|
if (successMaxPrice) {
|
||||||
|
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), inputDate);
|
||||||
|
}
|
||||||
return std::make_pair(s.toStdString(), inputDate);
|
return std::make_pair(s.toStdString(), inputDate);
|
||||||
} // if ((double)price == cost) {
|
} // if ((double)price == cost) {
|
||||||
else {
|
else {
|
||||||
@ -648,6 +661,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
if (overPaid) {
|
if (overPaid) {
|
||||||
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
|
if (successMaxPrice) {
|
||||||
|
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
|
||||||
|
}
|
||||||
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
||||||
} else {
|
} else {
|
||||||
QDateTime const dt = start;
|
QDateTime const dt = start;
|
||||||
@ -698,6 +714,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
if (overPaid) {
|
if (overPaid) {
|
||||||
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
|
if (successMaxPrice) {
|
||||||
|
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
|
||||||
|
}
|
||||||
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -796,6 +815,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
if (overPaid) {
|
if (overPaid) {
|
||||||
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
|
if (successMaxPrice) {
|
||||||
|
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
|
||||||
|
}
|
||||||
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -840,6 +862,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
if (overPaid) {
|
if (overPaid) {
|
||||||
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
|
if (successMaxPrice) {
|
||||||
|
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
|
||||||
|
}
|
||||||
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -874,6 +899,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
if (overPaid) {
|
if (overPaid) {
|
||||||
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
|
if (successMaxPrice) {
|
||||||
|
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
|
||||||
|
}
|
||||||
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -993,6 +1021,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
if (overPaid) {
|
if (overPaid) {
|
||||||
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
|
if (successMaxPrice) {
|
||||||
|
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
|
||||||
|
}
|
||||||
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,11 @@ OTHER_FILES += \
|
|||||||
/opt/ptu5/opt/customer_335/etc/psa_tariff/tariff02.json \
|
/opt/ptu5/opt/customer_335/etc/psa_tariff/tariff02.json \
|
||||||
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json \
|
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json \
|
||||||
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json \
|
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json \
|
||||||
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json
|
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json \
|
||||||
|
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff04.json \
|
||||||
|
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff05.json \
|
||||||
|
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff06.json \
|
||||||
|
/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff07.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user