diff --git a/library/src/calculate_price.cpp b/library/src/calculate_price.cpp index 935b872..b54fabd 100644 --- a/library/src/calculate_price.cpp +++ b/library/src/calculate_price.cpp @@ -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 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,