Compare commits

...

5 Commits

Author SHA1 Message Date
9b137c2873 Fix in Calculator::GetPriceForTimeStep():
Allow some tolerance (of 3 minutes) when looking up the
	current time-step value in the duration-array.
	Otherwise, when corossing a minute-boundary, it can happen to
	not find the match and returning a price of 0 (which is almost
	always wrong).
2025-04-03 11:53:47 +02:00
dd249a87d5 Set cnt-limit to 20. This allows a bigger time-range for tariff, which
have in principle no time-limit.
2025-04-02 15:28:46 +02:00
575885c19e Merge branch 'master' into kleipeda-experimental 2025-04-02 09:44:20 +02:00
d82a732a8d if end of parking time equals carry-over-end, then, if configured, go back to carry-over-start. 2025-04-01 14:26:21 +02:00
99dbd7c194 Minor: debug output. 2025-04-01 14:24:42 +02:00
2 changed files with 21 additions and 8 deletions

View File

@ -780,7 +780,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
// DEBUG
qCritical() << "compute_price_for_parking_ticket() " << endl
qCritical() << __func__ << ":" << __LINE__ << endl
<< " paymentOptionIndex: " << paymentOptionIndex << endl
<< " start_parking_time: " << start_parking_time << endl
<< " netto_parking_time: " << netto_parking_time << endl
@ -912,10 +912,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
if (carryOver == 1) {
QTime carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
QTime carryOverEnd = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end;
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;
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart:" << carryOverStart.toString(Qt::ISODate);
qCritical() << __func__ << ":" << __LINE__ << " carryOverEnd:" << carryOverEnd.toString(Qt::ISODate);
qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration:" << carryOverDuration;
// handle carry over
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
@ -941,12 +943,21 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
end_parking_time = end_parking_time.addSecs(carryOverDuration * 60);
} else
if (end_parking_time.time() == carryOverStart) {
qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
qCritical() << __func__ << ":" << __LINE__ << " end-parking-time:" << end_parking_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) {
end_parking_time = end_parking_time.addSecs(carryOverDuration * 60);
qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
qCritical() << __func__ << ":" << __LINE__ << "adapted end-parking-time:" << end_parking_time.toString(Qt::ISODate);
}
} else
if (end_parking_time.time() == carryOverEnd) {
qCritical() << __func__ << ":" << __LINE__ << " end-parking-time:" << end_parking_time.toString(Qt::ISODate);
qCritical() << __func__ << ":" << __LINE__ << " carryOverEnd:" << carryOverEnd.toString(Qt::ISODate);
ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
if (po.pop_apply_carry_over_to_ticket_endtime == false) {
end_parking_time = end_parking_time.addSecs(-carryOverDuration * 60);
qCritical() << __func__ << ":" << __LINE__ << "adapted end-parking-time:" << end_parking_time.toString(Qt::ISODate);
}
}
} else {

View File

@ -458,7 +458,7 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
arg(cost).arg(nettoParktimeForCost);
int cnt = 0;
while (++cnt < 10 && netto_parking_time_in_minutes < nettoParktimeForCost) {
while (++cnt < 20 && netto_parking_time_in_minutes < nettoParktimeForCost) {
// qCritical() << __func__ << ":" << __LINE__ << "cnt [" << cnt;
brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
@ -3584,7 +3584,9 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
}
if (timeStep == pun_duration) {
// allow some tolerance when searching for [timeStep == pun_duration]:
// this might happen when crossing minute boundaries
if (std::abs(timeStep - pun_duration) < 4) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
return price;
}