compute_duration_for_parking_ticket():

Fix: handle prepaid-setting for coin-insertion.
This commit is contained in:
Gerhard Hoffmann 2024-08-21 15:39:44 +02:00
parent 08a249f393
commit 7a6360f392

View File

@ -929,6 +929,25 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
}
if (start_parking_time.isValid()) {
// handle prepaid option
QDateTime effectiveStartTime(start_parking_time);
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()) {
ATBPrepaid const &p = prepaidOption.value();
if (p.never) {
qCritical() << __func__ << __LINE__ << "prepaid: no";
} else {
if (start_parking_time.time() < p.static_end) { // static_end: e.g. 08:00:00
effectiveStartTime.setTime(p.static_end);
} else
if (start_parking_time.time() > p.static_start) { // static_start: e.g. 22:00:00
effectiveStartTime.setTime(p.static_start);
}
}
}
QString cs = start_parking_time.toString(Qt::ISODate);
QString endTime = Calculator::GetInstance().GetDurationFromCost(
tariff,