Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
0b42406b0f |
@@ -10,7 +10,6 @@ class ATBTime {
|
||||
public:
|
||||
explicit ATBTime();
|
||||
explicit ATBTime(int h, int m, int s = 0, int ms = 0);
|
||||
explicit ATBTime(QString const &time);
|
||||
|
||||
int hour() const { return m_time.time().hour(); }
|
||||
int minute() const { return m_time.time().minute(); }
|
||||
|
@@ -25,7 +25,6 @@ public:
|
||||
pop_max_time = 0;
|
||||
pop_min_price = 0;
|
||||
pop_max_price = 0;
|
||||
pop_max_price_save = 0;
|
||||
pop_carry_over = -1;
|
||||
pop_carry_over_option_id = -1;
|
||||
pop_prepaid_option_id = -1;
|
||||
@@ -62,7 +61,6 @@ public:
|
||||
double pop_max_time;
|
||||
double pop_min_price;
|
||||
double pop_max_price;
|
||||
double pop_max_price_save;
|
||||
int pop_carry_over;
|
||||
int pop_carry_over_option_id;
|
||||
bool pop_truncate_last_interpolation_step;
|
||||
|
@@ -4,8 +4,6 @@
|
||||
#include <QTime>
|
||||
#include <QString>
|
||||
|
||||
#include "atb_time.h"
|
||||
|
||||
struct ATBPrepaid {
|
||||
int id;
|
||||
bool anytime;
|
||||
|
@@ -2,30 +2,18 @@
|
||||
|
||||
|
||||
ATBTime::ATBTime()
|
||||
: m_end(QDateTime::fromString("1970-01-02T00:00:00", Qt::ISODate))
|
||||
, m_time(QDateTime::fromString("1970-01-01T00:00:00", Qt::ISODate)) {
|
||||
: m_end(QDateTime::fromString("1970-01-02T00:00:00"))
|
||||
, m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
|
||||
}
|
||||
|
||||
ATBTime::ATBTime(int h, int m, int s, int ms)
|
||||
: m_end(QDateTime::fromString("1970-01-02T00:00:00", Qt::ISODate))
|
||||
, m_time(QDateTime::fromString("1970-01-01T00:00:00", Qt::ISODate)) {
|
||||
: m_end(QDateTime::fromString("1970-01-02T00:00:00"))
|
||||
, m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
|
||||
|
||||
QTime t(h, m, s, ms);
|
||||
m_time.setTime(t);
|
||||
}
|
||||
|
||||
ATBTime::ATBTime(QString const &t)
|
||||
: m_end(QDateTime::fromString("1970-01-02T00:00:00"))
|
||||
, m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
|
||||
|
||||
if (t == "24:00:00") {
|
||||
m_time = m_end;
|
||||
} else {
|
||||
m_time.setTime(QTime::fromString(t, Qt::ISODate));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QTime ATBTime::addMSecs(int ms) const {
|
||||
return m_time.time().addMSecs(ms);
|
||||
}
|
||||
|
@@ -77,7 +77,6 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
if (paymentOptionIndex == -1) {
|
||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||
}
|
||||
|
||||
int maxTime = 0;
|
||||
|
||||
switch(permitType) {
|
||||
@@ -684,9 +683,6 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
|
||||
}
|
||||
|
||||
tariff->getPaymentOptions(paymentOptionIndex).pop_max_price
|
||||
= tariff->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
|
||||
|
||||
double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_min_time;
|
||||
double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_max_time;
|
||||
|
||||
@@ -757,9 +753,6 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
}
|
||||
|
||||
tariff->getPaymentOptions(paymentOptionIndex).pop_max_price
|
||||
= tariff->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
|
||||
|
||||
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
||||
|
||||
@@ -885,9 +878,6 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
}
|
||||
}
|
||||
|
||||
effectiveStartTime.setTime(QTime(effectiveStartTime.time().hour(),
|
||||
effectiveStartTime.time().minute(), 0));
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:" << effectiveStartTime.toString(Qt::ISODate);
|
||||
|
||||
int const carryOver = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||
@@ -953,8 +943,6 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
//QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit();
|
||||
//end_parking_time.setTime(tlimit);
|
||||
|
||||
// max_price neu berechnen
|
||||
|
||||
calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
|
||||
.arg(end_parking_time.time().toString(Qt::ISODate)));
|
||||
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
||||
@@ -1091,10 +1079,6 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::STATIC) {
|
||||
// handle prepaid option
|
||||
QDateTime effectiveStartTime(start_parking_time);
|
||||
|
||||
effectiveStartTime.setTime(QTime(effectiveStartTime.time().hour(),
|
||||
effectiveStartTime.time().minute(), 0));
|
||||
|
||||
int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
|
||||
if (prepaidOption.has_value()) {
|
||||
@@ -1111,9 +1095,8 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
}
|
||||
}
|
||||
}
|
||||
QDateTime start(start_parking_time);
|
||||
start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
|
||||
QString cs = start.toString(Qt::ISODate);
|
||||
|
||||
QString cs = start_parking_time.toString(Qt::ISODate);
|
||||
|
||||
std::pair<std::string, QDateTime> p_endTime
|
||||
= Calculator::GetInstance().GetDurationFromCost(
|
||||
@@ -1128,12 +1111,6 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
if (endTime == CalcState::SUCCESS) {
|
||||
calcState.setDesc(QString("SUCCESS"));
|
||||
calcState.setStatus(endTime);
|
||||
qCritical() << __func__ << ":" << __LINE__ << "SUCCESS";
|
||||
} else
|
||||
if (endTime == CalcState::SUCCESS_MAXPRICE) {
|
||||
calcState.setDesc(QString("SUCCESS_MAXPRICE"));
|
||||
calcState.setStatus(endTime);
|
||||
qCritical() << __func__ << ":" << __LINE__ << "SUCCESS_MAXPRICE";
|
||||
} else
|
||||
if (endTime == CalcState::ERROR_PARSING_ZONE_NR) {
|
||||
calcState.setStatus(endTime);
|
||||
@@ -1191,14 +1168,8 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
} else {
|
||||
ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
|
||||
|
||||
ticketEndTime.setTime(QTime(ticketEndTime.time().hour(),
|
||||
ticketEndTime.time().minute(), 0));
|
||||
|
||||
int netto_parking_time = start_parking_time.secsTo(ticketEndTime) / 60;
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << ":" << __LINE__ << "step-config:" << pop_time_step_config;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "netto-parking-time" << netto_parking_time;
|
||||
|
||||
if (!ticketEndTime.isValid()) {
|
||||
calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
|
||||
@@ -1240,12 +1211,6 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
}
|
||||
|
||||
if (carryOverStart.isValid() && carryOverEnd.isValid() && carryOverDuration != -1) {
|
||||
|
||||
// note: in such a case (direct coins) carry-over has been handled
|
||||
// already in GetDurationFromCost()
|
||||
netto_parking_time -= carryOverDuration;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "netto-parking-time" << netto_parking_time;
|
||||
|
||||
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||
if (ticketEndTime.time() > carryOverStart) {
|
||||
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||
@@ -1271,85 +1236,23 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ticketEndTime.setTime(QTime(ticketEndTime.time().hour(),
|
||||
ticketEndTime.time().minute(), 0));
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
|
||||
|
||||
for (auto[itr, rangeEnd] = tariff->WeekDays.equal_range((Qt::DayOfWeek)(ticketEndTime.date().dayOfWeek()));
|
||||
itr != rangeEnd;
|
||||
++itr) {
|
||||
ATBWeekDay const &wd = itr->second;
|
||||
bool parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(start_parking_time,
|
||||
ticketEndTime,
|
||||
paymentOptionIndex);
|
||||
bool const parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(start_parking_time,
|
||||
ticketEndTime,
|
||||
paymentOptionIndex);
|
||||
if (parkTimeLimitViolated) {
|
||||
//QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit();
|
||||
//ticketEndTime.setTime(tlimit);
|
||||
|
||||
QList<int> const &stepList = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
|
||||
|
||||
QDateTime newTicketEndTime = ticketEndTime;
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "PARK-TIME VIOLATED";
|
||||
|
||||
for (int i = stepList.size() - 1; i > 0; --i) {
|
||||
// qCritical() << __func__ << ":" << __LINE__ << "step[" << i << "]" << stepList.at(i);
|
||||
|
||||
if (netto_parking_time > 0 && stepList.at(i) <= netto_parking_time) {
|
||||
int const diff = stepList.at(i-1) - stepList.at(i);
|
||||
newTicketEndTime = newTicketEndTime.addSecs(diff * 60);
|
||||
|
||||
// qCritical() << __func__ << ":" << __LINE__ << "new-ticket-end-time" << newTicketEndTime.toString(Qt::ISODate);
|
||||
|
||||
parkTimeLimitViolated
|
||||
= wd.getTariffCarryOverSettings()
|
||||
.parkingTimeLimitExceeded(start_parking_time, newTicketEndTime, paymentOptionIndex);
|
||||
|
||||
if (!parkTimeLimitViolated) {
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< "PARK-TIME NOT VIOLATED FOR" << newTicketEndTime.toString(Qt::ISODate);
|
||||
|
||||
int duration = stepList.at(i-1);
|
||||
|
||||
// qCritical() << __func__ << ":" << __LINE__ << "duration" << duration;
|
||||
|
||||
std::multimap<int, ATBDuration>::const_iterator it;
|
||||
for (it = tariff->Duration.cbegin();
|
||||
it != tariff->Duration.cend();
|
||||
++it) {
|
||||
if (duration == it->second.pun_duration) {
|
||||
|
||||
// qCritical() << __func__ << ":" << __LINE__ << "duration" << duration;
|
||||
|
||||
ATBPaymentOption &po = tariff->getPaymentOptions(paymentOptionIndex);
|
||||
int const pop_id = po.pop_id;
|
||||
for (auto[itr, rangeEnd] = tariff->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
|
||||
// qCritical() << __func__ << ":" << __LINE__ << "durationId" << durationId << it->second.pun_id;
|
||||
|
||||
// note: for this to work, Duration and PaymentRate must have
|
||||
// exactly the same structure
|
||||
if (durationId == it->second.pun_id) {
|
||||
int const pra_price = itr->second.pra_price;
|
||||
po.pop_max_price = pra_price;
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << "new max-price" << po.pop_max_price;
|
||||
|
||||
// note: ABOVE_MAX_PARKING_TIME would also be possible
|
||||
// but here max-parking-time is dynamic. And for
|
||||
// this dynamic value, opverpaid is actually correct
|
||||
|
||||
calcState.setDesc(CalcState::OVERPAID);
|
||||
calcState.setStatus(CalcState::OVERPAID);
|
||||
return calcState;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
|
||||
.arg(ticketEndTime.time().toString(Qt::ISODate)));
|
||||
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
||||
@@ -1369,9 +1272,7 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
return calcState.set(CalcState::State::INVALID_START_DATE);
|
||||
}
|
||||
|
||||
//return calcState.set(CalcState::State::SUCCESS);
|
||||
qCritical() << __func__ << ":" << __LINE__ << " calcState" << calcState.toString();
|
||||
return calcState;
|
||||
return calcState.set(CalcState::State::SUCCESS);
|
||||
}
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,
|
||||
|
@@ -533,16 +533,6 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
|
||||
//qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate);
|
||||
|
||||
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||
if (pop_carry_over) {
|
||||
int weekDay = inputDate.date().dayOfWeek();
|
||||
int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||
if (pop_carry_over_option_id != -1) {
|
||||
int const carryOverDuration = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
|
||||
inputDate = inputDate.addSecs(carryOverDuration * 60);
|
||||
}
|
||||
}
|
||||
|
||||
inputDate = inputDate.addSecs(durationInSecs);
|
||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
|
||||
|
@@ -1000,7 +1000,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
this->currentPaymentOptions.last().pop_min_time = k->value.GetDouble();
|
||||
} else if (strcmp(inner_obj_name, "pop_max_price") == 0) {
|
||||
this->currentPaymentOptions.last().pop_max_price = k->value.GetDouble();
|
||||
this->currentPaymentOptions.last().pop_max_price_save = k->value.GetDouble();
|
||||
} else if (strcmp(inner_obj_name, "pop_max_time") == 0) {
|
||||
this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
|
||||
} else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
|
||||
|
Reference in New Issue
Block a user