Compare commits
17 Commits
Neuhauser-
...
1c801f1053
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c801f1053 | |||
| 56fc95e33c | |||
| c0f81f174a | |||
| 6ba3963f25 | |||
| 1a350c0aeb | |||
| 15801be88e | |||
| 20e146d3c9 | |||
| 30768c6931 | |||
| 7933c826e6 | |||
| 9d5ddfc328 | |||
| 102607b71f | |||
| 81d515eb7f | |||
| ce61e5d3b2 | |||
| b6a0f5e8af | |||
| e0223b50f9 | |||
| 690267c388 | |||
| 9c19414e5a |
@@ -174,7 +174,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
QDateTime &start_parking_time,
|
QDateTime &start_parking_time,
|
||||||
int netto_parking_time,
|
int netto_parking_time,
|
||||||
QDateTime &end_parking_time, // return value
|
QDateTime &end_parking_time, // return value
|
||||||
struct price_t *price); // return value
|
struct price_t *price, // return value
|
||||||
|
bool prepaid = true);
|
||||||
|
|
||||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket( // deprecated
|
CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket( // deprecated
|
||||||
parking_tariff_t *tariff,
|
parking_tariff_t *tariff,
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ namespace Utilities {
|
|||||||
uint32_t getMinimalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
|
uint32_t getMinimalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
|
||||||
uint32_t getMaximalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
|
uint32_t getMaximalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
|
||||||
uint32_t getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId);
|
uint32_t getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId);
|
||||||
|
uint32_t getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId);
|
||||||
BusinessHours getBusinessHours(Configuration const *cfg, PaymentMethod methodId);
|
BusinessHours getBusinessHours(Configuration const *cfg, PaymentMethod methodId);
|
||||||
uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
|
uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
|
||||||
double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
|
double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
|
||||||
|
|||||||
@@ -78,17 +78,22 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, PERMIT_TY
|
|||||||
|
|
||||||
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) {
|
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) {
|
||||||
int maxPrice = -1;
|
int maxPrice = -1;
|
||||||
|
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
|
||||||
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)
|
||||||
int const key = cfg->getPaymentOptions().pop_id;
|
if (paymentMethodId == PaymentMethod::Progressive) {
|
||||||
int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes
|
maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
|
||||||
std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
|
} else { // PaymentMethod::Linear -> e.g. szeged
|
||||||
if (pv) {
|
int const key = cfg->getPaymentOptions().pop_id;
|
||||||
QVector<ATBPaymentRate> const &paymentRate = pv.value();
|
int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes
|
||||||
if (paymentRate.size() > 0) {
|
std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
|
||||||
int const price = paymentRate.at(0).pra_price; // price is given per hour
|
if (pv) {
|
||||||
maxPrice = qRound((maxTime * price) / 60.0f);
|
QVector<ATBPaymentRate> const &paymentRate = pv.value();
|
||||||
|
if (paymentRate.size() > 0) {
|
||||||
|
int const price = paymentRate.at(0).pra_price; // price is given per hour
|
||||||
|
maxPrice = qRound((maxTime * price) / 60.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@@ -217,7 +222,9 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
|||||||
|
|
||||||
// use tariff with structure as for instance Schnau, Koenigsee:
|
// use tariff with structure as for instance Schnau, Koenigsee:
|
||||||
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
||||||
if (paymentMethodId == PaymentMethod::Steps)
|
if ((paymentMethodId == PaymentMethod::Steps) ||
|
||||||
|
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
|
||||||
|
(paymentMethodId == PaymentMethod::Progressive))
|
||||||
{
|
{
|
||||||
const QList<int> stepList = Calculator::GetInstance().GetTimeSteps(tariff);
|
const QList<int> stepList = Calculator::GetInstance().GetTimeSteps(tariff);
|
||||||
qCritical() << " compute_next_timestep() timeSteps:" << stepList;
|
qCritical() << " compute_next_timestep() timeSteps:" << stepList;
|
||||||
@@ -345,7 +352,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
QDateTime &start_parking_time,
|
QDateTime &start_parking_time,
|
||||||
int netto_parking_time,
|
int netto_parking_time,
|
||||||
QDateTime &end_parking_time,
|
QDateTime &end_parking_time,
|
||||||
struct price_t *price)
|
struct price_t *price,
|
||||||
|
bool prepaid)
|
||||||
{
|
{
|
||||||
CalcState calcState;
|
CalcState calcState;
|
||||||
double minMin = tariff->getPaymentOptions().pop_min_time;
|
double minMin = tariff->getPaymentOptions().pop_min_time;
|
||||||
@@ -384,7 +392,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
start_parking_time, // starting time
|
start_parking_time, // starting time
|
||||||
end_parking_time, // return value: end time
|
end_parking_time, // return value: end time
|
||||||
netto_parking_time, // minutes, netto
|
netto_parking_time, // minutes, netto
|
||||||
false, true);
|
false, prepaid);
|
||||||
double minCost = tariff->getPaymentOptions().pop_min_price;
|
double minCost = tariff->getPaymentOptions().pop_min_price;
|
||||||
if (cost < minCost) {
|
if (cost < minCost) {
|
||||||
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
|
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
|
||||||
|
|||||||
@@ -157,6 +157,17 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
|
|
||||||
static const bool carryOverNotSet = Utilities::isCarryOverNotSet(cfg, paymentMethodId);
|
static const bool carryOverNotSet = Utilities::isCarryOverNotSet(cfg, paymentMethodId);
|
||||||
static const uint minParkingPrice = Utilities::getMinimalParkingPrice(cfg, paymentMethodId);
|
static const uint minParkingPrice = Utilities::getMinimalParkingPrice(cfg, paymentMethodId);
|
||||||
|
static const uint maxParkingPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
|
||||||
|
|
||||||
|
if (cost < minParkingPrice) {
|
||||||
|
qCritical() << QString("ERROR: COST < MIN_PARKING_PRICE (%1 < %2)").arg(cost).arg(minParkingPrice);
|
||||||
|
return QDateTime().toString(Qt::ISODate).toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cost > maxParkingPrice) {
|
||||||
|
qCritical() << QString("WARN: COST > MAX_PARKING_PRICE (%1 > %2)").arg(cost).arg(maxParkingPrice);
|
||||||
|
cost = maxParkingPrice;
|
||||||
|
}
|
||||||
|
|
||||||
Q_ASSERT_X(carryOverNotSet, __func__, "CARRYOVER SET (FOR KIRCHDORF)");
|
Q_ASSERT_X(carryOverNotSet, __func__, "CARRYOVER SET (FOR KIRCHDORF)");
|
||||||
Q_ASSERT_X(prepaid, __func__, "PREPAID NOT SET (FOR KIRCHDORF)");
|
Q_ASSERT_X(prepaid, __func__, "PREPAID NOT SET (FOR KIRCHDORF)");
|
||||||
@@ -220,6 +231,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
if (carryOverNotSet) {
|
if (carryOverNotSet) {
|
||||||
int range = 0;
|
int range = 0;
|
||||||
int minsToCarryOver = 0; // from one work-time to the other on the same day
|
int minsToCarryOver = 0; // from one work-time to the other on the same day
|
||||||
|
int minsUsed = 0;
|
||||||
QDateTime lastCurrent = QDateTime();
|
QDateTime lastCurrent = QDateTime();
|
||||||
|
|
||||||
auto timeRangeIt = cfg->TimeRange.cbegin();
|
auto timeRangeIt = cfg->TimeRange.cbegin();
|
||||||
@@ -235,7 +247,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
|
|
||||||
Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
|
Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
|
||||||
|
|
||||||
|
|
||||||
if (current.time() >= to) {
|
if (current.time() >= to) {
|
||||||
continue; // try to use next available work-time
|
continue; // try to use next available work-time
|
||||||
} else
|
} else
|
||||||
@@ -261,24 +272,29 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
int duration = timeRange.time_range_to_in_minutes_from_start -
|
int duration = timeRange.time_range_to_in_minutes_from_start -
|
||||||
timeRange.time_range_from_in_minutes_from_start;
|
timeRange.time_range_from_in_minutes_from_start;
|
||||||
|
|
||||||
if (current.addSecs(duration * 60).time() <= to) {
|
if (minsUsed > 0) {
|
||||||
for(const auto &x: cfg->PaymentRate) {
|
duration -= minsUsed;
|
||||||
ATBPaymentRate const rate = x.second;
|
minsUsed = 0;
|
||||||
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
}
|
||||||
if (minsToCarryOver > 0) {
|
|
||||||
durationMinutes -= minsToCarryOver;
|
|
||||||
durationMinutesNetto += minsToCarryOver;
|
|
||||||
durationMinutesBrutto += minsToCarryOver;
|
|
||||||
current = current.addSecs(minsToCarryOver*60);
|
|
||||||
minsToCarryOver = 0;
|
|
||||||
} else {
|
|
||||||
if (price >= cost) {
|
|
||||||
end_datetime = current;
|
|
||||||
return end_datetime.toString(Qt::ISODate).toStdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (current.addSecs(duration * 60).time() <= to) {
|
||||||
|
if (minsToCarryOver > 0) { // the price for this time range
|
||||||
|
// has been is paid already
|
||||||
|
durationMinutes -= duration;
|
||||||
|
durationMinutesNetto += duration;
|
||||||
|
durationMinutesBrutto += duration;
|
||||||
|
current = current.addSecs(duration*60);
|
||||||
|
minsToCarryOver = 0;
|
||||||
|
} else {
|
||||||
|
for(const auto &x: cfg->PaymentRate) {
|
||||||
|
ATBPaymentRate const rate = x.second;
|
||||||
|
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
||||||
price += (uint)rate.pra_price;
|
price += (uint)rate.pra_price;
|
||||||
|
|
||||||
|
if (price >= maxParkingPrice) {
|
||||||
|
price = maxParkingPrice;
|
||||||
|
}
|
||||||
|
|
||||||
durationMinutes -= duration;
|
durationMinutes -= duration;
|
||||||
durationMinutesNetto += duration;
|
durationMinutesNetto += duration;
|
||||||
durationMinutesBrutto += duration;
|
durationMinutesBrutto += duration;
|
||||||
@@ -289,8 +305,9 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
end_datetime = current;
|
end_datetime = current;
|
||||||
return end_datetime.toString(Qt::ISODate).toStdString();
|
return end_datetime.toString(Qt::ISODate).toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,21 +322,28 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
|
|
||||||
lastCurrent = current;
|
lastCurrent = current;
|
||||||
current.setTime(to);
|
current.setTime(to);
|
||||||
int const minsLeft = lastCurrent.secsTo(current) / 60;
|
minsUsed = lastCurrent.secsTo(current) / 60;
|
||||||
|
|
||||||
// mod duration: possibly discard some minutes in
|
// mod duration: possibly discard some minutes in
|
||||||
// the next time-range
|
// the next time-range
|
||||||
minsToCarryOver = (durationMinutes - minsLeft) % duration;
|
if (durationMinutes >= minsUsed) {
|
||||||
|
minsToCarryOver = durationMinutes - minsUsed;
|
||||||
|
}
|
||||||
|
|
||||||
durationMinutes -= minsLeft;
|
durationMinutes -= minsUsed;
|
||||||
durationMinutesNetto += minsLeft;
|
durationMinutesNetto += minsUsed;
|
||||||
durationMinutesBrutto += minsLeft;
|
durationMinutesBrutto += minsUsed;
|
||||||
|
|
||||||
if (minsLeft > 0) {
|
if (minsUsed > 0) {
|
||||||
for(const auto &x: cfg->PaymentRate) {
|
for(const auto &x: cfg->PaymentRate) {
|
||||||
ATBPaymentRate const rate = x.second;
|
ATBPaymentRate const rate = x.second;
|
||||||
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
||||||
price += (uint)rate.pra_price;
|
price += (uint)rate.pra_price;
|
||||||
|
|
||||||
|
if (price >= maxParkingPrice) {
|
||||||
|
price = maxParkingPrice;
|
||||||
|
}
|
||||||
|
|
||||||
if (price >= cost) {
|
if (price >= cost) {
|
||||||
end_datetime = current;
|
end_datetime = current;
|
||||||
// return end_datetime.toString(Qt::ISODate).toStdString();
|
// return end_datetime.toString(Qt::ISODate).toStdString();
|
||||||
@@ -328,7 +352,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -473,9 +496,11 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
|||||||
end_datetime.setTime(cs.getAllowedTimeRange().getTimeUntil());
|
end_datetime.setTime(cs.getAllowedTimeRange().getTimeUntil());
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// it might be that in such a case even prepaid ("vorkauf")
|
||||||
|
// is not allowed at any moment
|
||||||
}
|
}
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "NOT YET IMPLEMENTED";
|
||||||
qCritical() << __PRETTY_FUNCTION__ << "NOT YET IMPLEMENTED";
|
|
||||||
end_datetime = QDateTime();
|
end_datetime = QDateTime();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -527,6 +552,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
|||||||
|
|
||||||
if (current.time() >= to) {
|
if (current.time() >= to) {
|
||||||
if (carryOverNotSet) {
|
if (carryOverNotSet) {
|
||||||
|
end_datetime = start;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
QDateTime const dt = start;
|
QDateTime const dt = start;
|
||||||
@@ -547,6 +573,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
|||||||
if (carryOverNotSet) {
|
if (carryOverNotSet) {
|
||||||
int range = 0;
|
int range = 0;
|
||||||
int minsToCarryOver = 0; // from one work-time to the other on the same day
|
int minsToCarryOver = 0; // from one work-time to the other on the same day
|
||||||
|
int minsUsed = 0;
|
||||||
QDateTime lastCurrent = QDateTime();
|
QDateTime lastCurrent = QDateTime();
|
||||||
|
|
||||||
auto timeRangeIt = cfg->TimeRange.cbegin();
|
auto timeRangeIt = cfg->TimeRange.cbegin();
|
||||||
@@ -562,7 +589,6 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
|||||||
|
|
||||||
Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
|
Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
|
||||||
|
|
||||||
|
|
||||||
if (current.time() >= to) {
|
if (current.time() >= to) {
|
||||||
continue; // try to use next available work-time
|
continue; // try to use next available work-time
|
||||||
} else
|
} else
|
||||||
@@ -588,18 +614,23 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
|||||||
int duration = timeRange.time_range_to_in_minutes_from_start -
|
int duration = timeRange.time_range_to_in_minutes_from_start -
|
||||||
timeRange.time_range_from_in_minutes_from_start;
|
timeRange.time_range_from_in_minutes_from_start;
|
||||||
|
|
||||||
if (current.addSecs(duration * 60).time() <= to) {
|
if (minsUsed > 0) {
|
||||||
|
duration -= minsUsed;
|
||||||
|
minsUsed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for(const auto &x: cfg->PaymentRate) {
|
if (current.addSecs(duration * 60).time() <= to) {
|
||||||
ATBPaymentRate const rate = x.second;
|
if (minsToCarryOver > 0) { // the price for this time range
|
||||||
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
// has been is paid already
|
||||||
if (minsToCarryOver > 0) {
|
durationMinutes -= duration;
|
||||||
durationMinutes -= minsToCarryOver;
|
durationMinutesNetto += duration;
|
||||||
durationMinutesNetto += minsToCarryOver;
|
durationMinutesBrutto += duration;
|
||||||
durationMinutesBrutto += minsToCarryOver;
|
current = current.addSecs(duration*60);
|
||||||
current = current.addSecs(minsToCarryOver*60);
|
minsToCarryOver = 0;
|
||||||
minsToCarryOver = 0;
|
} else {
|
||||||
} else {
|
for(const auto &x: cfg->PaymentRate) {
|
||||||
|
ATBPaymentRate const rate = x.second;
|
||||||
|
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
||||||
price += (uint)rate.pra_price;
|
price += (uint)rate.pra_price;
|
||||||
|
|
||||||
durationMinutes -= duration;
|
durationMinutes -= duration;
|
||||||
@@ -607,8 +638,8 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
|||||||
durationMinutesBrutto += duration;
|
durationMinutesBrutto += duration;
|
||||||
|
|
||||||
current = current.addSecs(duration * 60);
|
current = current.addSecs(duration * 60);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,17 +654,19 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
|||||||
|
|
||||||
lastCurrent = current;
|
lastCurrent = current;
|
||||||
current.setTime(to);
|
current.setTime(to);
|
||||||
int const minsLeft = lastCurrent.secsTo(current) / 60;
|
minsUsed = lastCurrent.secsTo(current) / 60;
|
||||||
|
|
||||||
// mod duration: possibly discard some minutes in
|
// mod duration: possibly discard some minutes in
|
||||||
// the next time-range
|
// the next time-range
|
||||||
minsToCarryOver = (durationMinutes - minsLeft) % duration;
|
if (durationMinutes >= minsUsed) {
|
||||||
|
minsToCarryOver = durationMinutes - minsUsed;
|
||||||
|
}
|
||||||
|
|
||||||
durationMinutes -= minsLeft;
|
durationMinutes -= minsUsed;
|
||||||
durationMinutesNetto += minsLeft;
|
durationMinutesNetto += minsUsed;
|
||||||
durationMinutesBrutto += minsLeft;
|
durationMinutesBrutto += minsUsed;
|
||||||
|
|
||||||
if (minsLeft > 0) {
|
if (minsUsed > 0) {
|
||||||
for(const auto &x: cfg->PaymentRate) {
|
for(const auto &x: cfg->PaymentRate) {
|
||||||
ATBPaymentRate const rate = x.second;
|
ATBPaymentRate const rate = x.second;
|
||||||
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
||||||
@@ -642,7 +675,6 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1145,6 +1177,8 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
|||||||
int const pop_carry_over = cfg->getPaymentOptions().pop_carry_over;
|
int const pop_carry_over = cfg->getPaymentOptions().pop_carry_over;
|
||||||
int const pop_time_step_config = cfg->getPaymentOptions().pop_time_step_config;
|
int const pop_time_step_config = cfg->getPaymentOptions().pop_time_step_config;
|
||||||
|
|
||||||
|
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << " start parking time:" << start.toString(Qt::ISODate);
|
qCritical() << __func__ << ":" << __LINE__ << " start parking time:" << start.toString(Qt::ISODate);
|
||||||
qCritical() << __func__ << ":" << __LINE__ << " payment option id:" << pop_id;
|
qCritical() << __func__ << ":" << __LINE__ << " payment option id:" << pop_id;
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "payment option carry over:" << pop_carry_over;
|
qCritical() << __func__ << ":" << __LINE__ << "payment option carry over:" << pop_carry_over;
|
||||||
@@ -1152,63 +1186,71 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
|||||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
||||||
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
||||||
|
|
||||||
uint16_t timeStepCompensation = 0;
|
if (paymentMethodId == PaymentMethod::Progressive) { // e.g. neuhauser kirchdorf (743)
|
||||||
|
std::size_t const s = cfg->TimeRange.size();
|
||||||
|
for (std::size_t id = 1; id <= s; ++id) {
|
||||||
|
int const step = Utilities::getTimeRangeStep(cfg, id, paymentMethodId);
|
||||||
|
m_timeSteps.append(step);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uint16_t timeStepCompensation = 0;
|
||||||
|
|
||||||
if (pop_carry_over) {
|
if (pop_carry_over) {
|
||||||
int const pop_carry_over_time_range_id = cfg->getPaymentOptions().pop_carry_over_time_range_id;
|
int const pop_carry_over_time_range_id = cfg->getPaymentOptions().pop_carry_over_time_range_id;
|
||||||
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
||||||
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
||||||
|
|
||||||
if (carryOverTimeRangeFrom.secsTo(carryOverTimeRangeTo) <= 60) { // carry over time point, usually 00:00:00
|
if (carryOverTimeRangeFrom.secsTo(carryOverTimeRangeTo) <= 60) { // carry over time point, usually 00:00:00
|
||||||
if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||||
int const durationId = itr->second.pra_payment_unit_id;
|
int const durationId = itr->second.pra_payment_unit_id;
|
||||||
auto search = cfg->Duration.find(durationId);
|
auto search = cfg->Duration.find(durationId);
|
||||||
if (search != cfg->Duration.end()) {
|
if (search != cfg->Duration.end()) {
|
||||||
ATBDuration duration = search->second;
|
ATBDuration duration = search->second;
|
||||||
if (durationId == 1) {
|
if (durationId == 1) {
|
||||||
QDateTime carryOver = start;
|
QDateTime carryOver = start;
|
||||||
carryOver = carryOver.addDays(1);
|
carryOver = carryOver.addDays(1);
|
||||||
carryOver.setTime(QTime(0, 0, 0));
|
carryOver.setTime(QTime(0, 0, 0));
|
||||||
|
|
||||||
int const timeStep = std::ceil(start.secsTo(carryOver) / 60.0);
|
int const timeStep = std::ceil(start.secsTo(carryOver) / 60.0);
|
||||||
if (timeStep < duration.pun_duration_min || timeStep > duration.pun_duration_max) {
|
if (timeStep < duration.pun_duration_min || timeStep > duration.pun_duration_max) {
|
||||||
qCritical()
|
qCritical()
|
||||||
<< QString("ERROR timeStep (%1) < durationMin (%2) || timeStep (%3)) > durationMax (%4)")
|
<< QString("ERROR timeStep (%1) < durationMin (%2) || timeStep (%3)) > durationMax (%4)")
|
||||||
.arg(timeStep).arg(duration.pun_duration_min)
|
.arg(timeStep).arg(duration.pun_duration_min)
|
||||||
.arg(timeStep).arg(duration.pun_duration_max);
|
.arg(timeStep).arg(duration.pun_duration_max);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
qCritical() << __PRETTY_FUNCTION__ << "configured minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
||||||
|
|
||||||
|
// set dynamic minimal parking time
|
||||||
|
cfg->getPaymentOptions().pop_min_time = timeStep;
|
||||||
|
|
||||||
|
qCritical() << __PRETTY_FUNCTION__ << " computed minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
||||||
|
|
||||||
|
duration.pun_duration = timeStep;
|
||||||
|
timeStepCompensation = duration.pun_duration_max - duration.pun_duration;
|
||||||
|
m_timeSteps << duration.pun_duration;
|
||||||
|
} else {
|
||||||
|
duration.pun_duration = duration.pun_duration_max - timeStepCompensation;
|
||||||
|
m_timeSteps << duration.pun_duration;;
|
||||||
}
|
}
|
||||||
qCritical() << __PRETTY_FUNCTION__ << "configured minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
|
||||||
|
|
||||||
// set dynamic minimal parking time
|
cfg->Duration.erase(search);
|
||||||
cfg->getPaymentOptions().pop_min_time = timeStep;
|
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
||||||
|
|
||||||
qCritical() << __PRETTY_FUNCTION__ << " computed minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
} else { // if (search != cfg->Duration.end()) {
|
||||||
|
// TODO
|
||||||
duration.pun_duration = timeStep;
|
|
||||||
timeStepCompensation = duration.pun_duration_max - duration.pun_duration;
|
|
||||||
m_timeSteps << duration.pun_duration;
|
|
||||||
} else {
|
|
||||||
duration.pun_duration = duration.pun_duration_max - timeStepCompensation;
|
|
||||||
m_timeSteps << duration.pun_duration;;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg->Duration.erase(search);
|
|
||||||
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
|
||||||
|
|
||||||
} else { // if (search != cfg->Duration.end()) {
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
} else { // if (carryOverTimeRangeFrom == carryOverTimeRangeTo) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
} else { // if (carryOverTimeRangeFrom == carryOverTimeRangeTo) {
|
} else { // if (pop_carry_over) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
} else { // if (pop_carry_over) {
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::STATIC";
|
qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::STATIC";
|
||||||
|
|||||||
@@ -397,6 +397,14 @@ uint32_t Utilities::getMaximalParkingPrice(Configuration const *cfg, PaymentMeth
|
|||||||
return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0);
|
return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Utilities::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) {
|
||||||
|
if (methodId == PaymentMethod::Progressive) {
|
||||||
|
return std::max((int)cfg->TimeRange.find(step)->second.time_range_to_in_minutes_from_start, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t Utilities::getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId) {
|
uint32_t Utilities::getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId) {
|
||||||
|
|
||||||
int const popId = cfg->PaymentOption.find(methodId)->second.pop_id;
|
int const popId = cfg->PaymentOption.find(methodId)->second.pop_id;
|
||||||
|
|||||||
356
main/main.cpp
356
main/main.cpp
@@ -27,6 +27,7 @@ extern "C" char* strptime(const char* s,
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -36,11 +37,126 @@ extern "C" char* strptime(const char* s,
|
|||||||
#define SZEGED (0)
|
#define SZEGED (0)
|
||||||
#define SCHOENAU_KOENIGSEE (0)
|
#define SCHOENAU_KOENIGSEE (0)
|
||||||
#define NEUHAUSER_KORNEUBURG (0)
|
#define NEUHAUSER_KORNEUBURG (0)
|
||||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
|
#define NEUHAUSER_LINSINGER_MASCHINENBAU (1)
|
||||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||||
#define NEUHAUSER_KIRCHDORF (1)
|
#define NEUHAUSER_KIRCHDORF (0)
|
||||||
|
|
||||||
|
#if NEUHAUSER_KIRCHDORF==1
|
||||||
|
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||||
|
switch (step) {
|
||||||
|
case 30:
|
||||||
|
if (cost != 30) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 30;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 35:
|
||||||
|
if (cost != 40) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 40;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 40:
|
||||||
|
if (cost != 50) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 50;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 45:
|
||||||
|
if (cost != 60) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 60;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 50:
|
||||||
|
if (cost != 70) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 70;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 55:
|
||||||
|
if (cost != 80) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 80;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 60:
|
||||||
|
if (cost != 90) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 90;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 65:
|
||||||
|
if (cost != 100) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 100;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 70:
|
||||||
|
if (cost != 110) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 110;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 75:
|
||||||
|
if (cost != 120) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 120;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 80:
|
||||||
|
if (cost != 130) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 130;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 85:
|
||||||
|
if (cost != 140) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 140;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
if (cost != 150) {
|
||||||
|
qCritical() << "ERROR COMPUTING COST"
|
||||||
|
<< "HAVE" << cost
|
||||||
|
<< "SHOULD" << 150;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
#if SCHOENAU_KOENIGSEE==1
|
#if SCHOENAU_KOENIGSEE==1
|
||||||
@@ -89,6 +205,160 @@ int main() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NEUHAUSER_KIRCHDORF==1
|
#if NEUHAUSER_KIRCHDORF==1
|
||||||
|
if (QDir("/opt/app/tools/atbupdate/customer_743").exists()) {
|
||||||
|
if(QFileInfo::exists("/etc/psa_tariff/tariff01.json")) {
|
||||||
|
// if (true) {
|
||||||
|
// if(true) {
|
||||||
|
const char *f = "/etc/psa_tariff/tariff01.json";
|
||||||
|
// const char *f = "/opt/ptu5/opt/customer_743/etc/psa_tariff/tariff01.json";
|
||||||
|
std::ifstream input(f);
|
||||||
|
|
||||||
|
std::stringstream sstr;
|
||||||
|
while(input >> sstr.rdbuf());
|
||||||
|
std::string json(sstr.str());
|
||||||
|
|
||||||
|
Configuration cfg;
|
||||||
|
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
||||||
|
|
||||||
|
if (!isParsed) {
|
||||||
|
qCritical() << "ERROR: CANNOT PARSE" << f;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
qCritical() << "Successfully parsed" << f;
|
||||||
|
|
||||||
|
int const minParkingTime = get_minimal_parkingtime(&cfg);
|
||||||
|
int const maxParkingTime = get_maximal_parkingtime(&cfg);
|
||||||
|
int const minParkingPrice = get_minimal_parkingprice(&cfg);
|
||||||
|
|
||||||
|
if (minParkingTime != 30) {
|
||||||
|
qCritical() << "ERROR: WRONG MIN_PARKING_TIME" << minParkingTime;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
qCritical() << "min_parking_time " << minParkingTime;
|
||||||
|
|
||||||
|
if (maxParkingTime != 90) {
|
||||||
|
qCritical() << "ERROR: WRONG MAX_PARKING_TIME" << maxParkingTime;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
qCritical() << "max_parking_time " << maxParkingTime;
|
||||||
|
|
||||||
|
|
||||||
|
if (minParkingPrice != 30) {
|
||||||
|
qCritical() << "ERROR: WRONG MIN_PARKING_PRICE" << minParkingPrice;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
qCritical() << "min_parking_price" << minParkingPrice;
|
||||||
|
|
||||||
|
QList<int> const stepsConfigured
|
||||||
|
= QList(std::initializer_list<int>{
|
||||||
|
30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90});
|
||||||
|
|
||||||
|
QList<int> const steps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||||
|
|
||||||
|
if (stepsConfigured != steps) {
|
||||||
|
qCritical() << "ERROR: WRONG TIME-STEP-LIST" << steps;
|
||||||
|
qCritical() << "SHOULD BE" << stepsConfigured;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
qCritical() << "time steps" << steps;
|
||||||
|
|
||||||
|
QDateTime s(QDate(2024, 2, 21), QTime());
|
||||||
|
QDateTime end;
|
||||||
|
struct price_t price;
|
||||||
|
|
||||||
|
QList<int>::const_iterator step;
|
||||||
|
for (step = steps.cbegin(); step != steps.cend(); ++step) {
|
||||||
|
qCritical() << QString("*** NEXT STEP: %1 ***").arg(*step);
|
||||||
|
for (int offset = 7*60; offset < 18*60; ++offset) {
|
||||||
|
QDateTime start = s.addSecs(offset * 60);
|
||||||
|
QDateTime const firstStart = start;
|
||||||
|
|
||||||
|
if (compute_price_for_parking_ticket(&cfg, start, *step, end, &price)) {
|
||||||
|
double cost = price.netto;
|
||||||
|
|
||||||
|
//qCritical() << "****" << offset << *step << "****";
|
||||||
|
//qCritical() << " firstStart :" << firstStart.toString(Qt::ISODate);
|
||||||
|
//qCritical() << " start :" << start.toString(Qt::ISODate);
|
||||||
|
//qCritical() << " end :" << end.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
if (offset < 8*60) { // [7:00 - 8:00[
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (offset < 9*60) { // [8:00 - 9:00[
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (offset < 10*60) {
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (offset < 11*60) {
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (offset < 12*60) {
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (offset < 13*60) {
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (offset < 14*60) {
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (offset < 15*60) {
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (offset < 16*60) {
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (offset < 17*60) {
|
||||||
|
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||||
|
qCritical() << "ERROR AT OFFSET" << offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qCritical() << "WARN OFFSET TOO HIGH" << offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
qCritical() << "ERROR COMPUTING PRICE FOR"
|
||||||
|
<< "start" << start.toString(Qt::ISODate)
|
||||||
|
<< "step" << *step
|
||||||
|
<< "end" << end.toString(Qt::ISODate);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
const char *f = "/opt/ptu5/opt/customer_743/etc/psa_tariff/tariff01.json";
|
const char *f = "/opt/ptu5/opt/customer_743/etc/psa_tariff/tariff01.json";
|
||||||
std::ifstream input(f);
|
std::ifstream input(f);
|
||||||
|
|
||||||
@@ -110,18 +380,18 @@ int main() {
|
|||||||
qCritical() << "max_parking_time " << maxParkingTime;
|
qCritical() << "max_parking_time " << maxParkingTime;
|
||||||
qCritical() << "min_parking_price" << minParkingPrice;
|
qCritical() << "min_parking_price" << minParkingPrice;
|
||||||
|
|
||||||
#if 1
|
|
||||||
bool nextDay = false;
|
bool nextDay = false;
|
||||||
bool prePaid = true;
|
bool prePaid = true;
|
||||||
// bool carryOver = false;
|
// bool carryOver = false;
|
||||||
|
|
||||||
QDateTime s(QDate(2023, 11, 30), QTime());
|
//QDateTime s = QDateTime::currentDateTime();
|
||||||
// QDateTime s(QDate(2023, 11, 26), QTime());
|
QDateTime s(QDate(2024, 2, 21), QTime());
|
||||||
QDateTime end;
|
QDateTime end;
|
||||||
for (int duration = 30; duration <= 90; duration += 5) {
|
for (int duration = 30; duration <= 90; duration += 5) {
|
||||||
// for (int duration = 30; duration <= maxParkingTime; duration += 5) {
|
// for (int duration = 30; duration <= maxParkingTime; duration += 5) {
|
||||||
qCritical() << "";
|
qCritical() << "";
|
||||||
for (int offset = 420; offset <= 1080; ++offset) {
|
for (int offset = 420; offset <= 1080; ++offset) {
|
||||||
|
//for (int offset = 0; offset <= 0; ++offset) {
|
||||||
//for (int offset = 420; offset <= 1080; ++offset) {
|
//for (int offset = 420; offset <= 1080; ++offset) {
|
||||||
//if (offset > 720 && offset < 840) {
|
//if (offset > 720 && offset < 840) {
|
||||||
// continue;
|
// continue;
|
||||||
@@ -130,7 +400,12 @@ int main() {
|
|||||||
QDateTime const firstStart = start;
|
QDateTime const firstStart = start;
|
||||||
// qCritical() << "start" << start.toString(Qt::ISODate);
|
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||||
|
|
||||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 1, start, end, duration, nextDay, prePaid);
|
// double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 1, start, end, duration, nextDay, prePaid);
|
||||||
|
|
||||||
|
struct price_t price;
|
||||||
|
compute_price_for_parking_ticket(&cfg, start, duration, end, &price);
|
||||||
|
|
||||||
|
double cost = price.netto;
|
||||||
|
|
||||||
//#if COST_FROM_DURATION==0
|
//#if COST_FROM_DURATION==0
|
||||||
double cost_soll = 30 + ((duration-30)/5 * 10);
|
double cost_soll = 30 + ((duration-30)/5 * 10);
|
||||||
@@ -140,54 +415,52 @@ int main() {
|
|||||||
duration_ist = duration_ist - 120;
|
duration_ist = duration_ist - 120;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qCritical() << "****" << offset << duration << "****";
|
qCritical() << "****" << offset << duration << "****";
|
||||||
qCritical() << " firstStart :" << firstStart.toString(Qt::ISODate);
|
qCritical() << " firstStart :" << firstStart.toString(Qt::ISODate);
|
||||||
qCritical() << " start :" << start.toString(Qt::ISODate);
|
qCritical() << " start :" << start.toString(Qt::ISODate);
|
||||||
qCritical() << " end :" << end.toString(Qt::ISODate);
|
qCritical() << " end :" << end.toString(Qt::ISODate);
|
||||||
qCritical() << "duration (soll):" << duration;
|
//qCritical() << "duration (soll):" << duration;
|
||||||
qCritical() << "duration (ist) :" << duration_ist;
|
//qCritical() << "duration (ist) :" << duration_ist;
|
||||||
qCritical() << " cost (soll):" << cost_soll;
|
//qCritical() << " cost (soll):" << cost_soll;
|
||||||
qCritical() << " cost (ist) :" << cost;
|
//qCritical() << " cost (ist) :" << cost;
|
||||||
|
|
||||||
if (cost_soll != cost) {
|
// if (cost_soll != cost) {
|
||||||
//qCritical() << "ERROR" << __func__ << ":" << __LINE__
|
//qCritical() << "ERROR" << __func__ << ":" << __LINE__
|
||||||
// << "cost_soll" << cost_soll << "cost_ist" << cost;
|
// << "cost_soll" << cost_soll << "cost_ist" << cost;
|
||||||
//break;
|
//break;
|
||||||
}
|
// }
|
||||||
if (duration != duration_ist) {
|
// if (duration != duration_ist) {
|
||||||
//qCritical() << "ERROR" << __func__ << ":" << __LINE__
|
//qCritical() << "ERROR" << __func__ << ":" << __LINE__
|
||||||
// << "duration_soll" << duration << "duration_ist" << duration_ist;
|
// << "duration_soll" << duration << "duration_ist" << duration_ist;
|
||||||
//break;
|
//break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//#else
|
//#else
|
||||||
start = s.addSecs(offset * 60);
|
//start = s.addSecs(offset * 60);
|
||||||
std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 1,
|
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 1,
|
||||||
start.toString(Qt::ISODate).toStdString().c_str(),
|
// start.toString(Qt::ISODate).toStdString().c_str(),
|
||||||
cost, false, true);
|
// cost, false, true);
|
||||||
|
|
||||||
|
|
||||||
if (end.toString(Qt::ISODate) != QString(duration.c_str())) {
|
//if (end.toString(Qt::ISODate) != QString(duration.c_str())) {
|
||||||
//qCritical() << "ERROR" << end.toString(Qt::ISODate)
|
//qCritical() << "ERROR" << end.toString(Qt::ISODate)
|
||||||
// << QString(duration.c_str());
|
// << QString(duration.c_str());
|
||||||
//break;
|
//break;
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||||
<< "cost" << cost
|
// << "cost" << cost
|
||||||
<< "until" << duration.c_str()
|
// << "until" << duration.c_str()
|
||||||
<< "end" << end.toString(Qt::ISODate)
|
// << "end" << end.toString(Qt::ISODate)
|
||||||
<< ":" << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60
|
// << ":" << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60
|
||||||
<< (end.toString(Qt::ISODate) == QString(duration.c_str()));
|
// << (end.toString(Qt::ISODate) == QString(duration.c_str()));
|
||||||
|
|
||||||
//#endif // COST_FROM_DURATION
|
//#endif // COST_FROM_DURATION
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // 0
|
#endif // 0
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NEUHAUSER_BILEXA_GALTUER==1
|
#if NEUHAUSER_BILEXA_GALTUER==1
|
||||||
@@ -239,6 +512,9 @@ int main() {
|
|||||||
QDateTime s(QDate(2023, 11, 30), QTime());
|
QDateTime s(QDate(2023, 11, 30), QTime());
|
||||||
QDateTime end;
|
QDateTime end;
|
||||||
struct price_t price;
|
struct price_t price;
|
||||||
|
#define ADULT 0
|
||||||
|
#define TEEN 1
|
||||||
|
#if ADULT==1
|
||||||
for (int offset = 480; offset < 1080; ++offset) {
|
for (int offset = 480; offset < 1080; ++offset) {
|
||||||
QDateTime start = s.addSecs(offset * 60);
|
QDateTime start = s.addSecs(offset * 60);
|
||||||
|
|
||||||
@@ -249,7 +525,9 @@ int main() {
|
|||||||
qCritical() << "start=" << start.toString(Qt::ISODate)
|
qCritical() << "start=" << start.toString(Qt::ISODate)
|
||||||
<< "end" << end.toString(Qt::ISODate) << "price" << price.netto;
|
<< "end" << end.toString(Qt::ISODate) << "price" << price.netto;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if TEEN==1
|
||||||
for (int offset = 480; offset < 1080; ++offset) {
|
for (int offset = 480; offset < 1080; ++offset) {
|
||||||
QDateTime start = s.addSecs(offset * 60);
|
QDateTime start = s.addSecs(offset * 60);
|
||||||
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
||||||
@@ -257,6 +535,7 @@ int main() {
|
|||||||
qCritical() << "start=" << start.toString(Qt::ISODate)
|
qCritical() << "start=" << start.toString(Qt::ISODate)
|
||||||
<< "end" << end.toString(Qt::ISODate) << "price" << price.netto;
|
<< "end" << end.toString(Qt::ISODate) << "price" << price.netto;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -282,16 +561,23 @@ int main() {
|
|||||||
QDateTime end;
|
QDateTime end;
|
||||||
int marken[] = { 3*60, 5*60, 10*60};
|
int marken[] = { 3*60, 5*60, 10*60};
|
||||||
for (int duration = 0; duration < 3; ++duration) {
|
for (int duration = 0; duration < 3; ++duration) {
|
||||||
for (int offset = 360; offset <= 1080; ++offset) {
|
for (int offset = 360; offset <= 360; ++offset) {
|
||||||
|
// for (int offset = 360; offset < 1080; ++offset) {
|
||||||
QDateTime start = s.addSecs(offset * 60);
|
QDateTime start = s.addSecs(offset * 60);
|
||||||
//qCritical() << "start" << start.toString(Qt::ISODate);
|
//qCritical() << "start" << start.toString(Qt::ISODate);
|
||||||
|
|
||||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 4, start, end, marken[duration], nextDay, prePaid);
|
// note: prepaid == false (!)
|
||||||
//qCritical() << "";
|
// double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 4, start, end, marken[duration], nextDay, prePaid);
|
||||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
|
||||||
<< "end" << end.toString(Qt::ISODate)
|
struct price_t price;
|
||||||
<< "duration" << marken[duration]
|
if (compute_price_for_parking_ticket(&cfg, start, marken[duration], end, &price, prePaid)) {
|
||||||
<< "cost" << cost;
|
double cost = price.netto;
|
||||||
|
|
||||||
|
qCritical() << "start" << start.toString(Qt::ISODate)
|
||||||
|
<< "end" << end.toString(Qt::ISODate)
|
||||||
|
<< "duration" << marken[duration]
|
||||||
|
<< "cost" << cost;
|
||||||
|
}
|
||||||
|
|
||||||
//std::string d = Calculator::GetInstance().GetDurationFromCost(&cfg, 4, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
//std::string d = Calculator::GetInstance().GetDurationFromCost(&cfg, 4, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||||
|
|||||||
Reference in New Issue
Block a user