From 1be07a2415218e0ed6c91963f4d59fcc8ff4d93e Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Mon, 12 Aug 2024 09:16:26 +0200 Subject: [PATCH] get_minimal_parkingtime(): compute_price_for_parking_ticket(): Minor: changed debug output. --- library/src/calculate_price.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/library/src/calculate_price.cpp b/library/src/calculate_price.cpp index 935b872..e959e00 100644 --- a/library/src/calculate_price.cpp +++ b/library/src/calculate_price.cpp @@ -36,10 +36,11 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg, int paymentOptionIndex) { int minTime = 0; + qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString(); + paymentOptionIndex = cfg->getPaymentOptionIndex(permitType); qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex; - qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString(); switch(permitType) { case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) @@ -723,9 +724,14 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType); + QList tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex); + //Q_UNUSED(tlist); + double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time; double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time; + // netto_parking_time = minMin; + // DEBUG qCritical() << "compute_price_for_parking_ticket() " << endl << " paymentOptionIndex: " << paymentOptionIndex << endl @@ -733,8 +739,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( << " netto_parking_time: " << netto_parking_time << endl << " start + netto: " << start_parking_time.addSecs(netto_parking_time * 60) << endl << " minMin: " << minMin << endl - << " maxMin: " << maxMin - << " prepaid: " << prepaid + << " maxMin: " << maxMin << endl + << " prepaid: " << prepaid << endl << " permitType: " << permitType.toString(); if (netto_parking_time < 0) { @@ -743,14 +749,17 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( start_parking_time.toString(Qt::ISODate))); return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME); } + if (netto_parking_time > maxMin) { calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin)); return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME); } + if (netto_parking_time < minMin) { calcState.setDesc(QString("duration=%1, minMin=%2").arg(netto_parking_time).arg(minMin)); return calcState.set(CalcState::State::BELOW_MIN_PARKING_TIME); } + if (netto_parking_time == 0) { return calcState.set(CalcState::State::SUCCESS); } @@ -768,15 +777,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( return calcState; } - QList tlist = Calculator::GetInstance().GetTimeSteps(tariff); - Q_UNUSED(tlist); // compute cost (price) cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex); int weekDay = start_parking_time.date().dayOfWeek(); int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id; - qCritical() << __func__ << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id; std::optional yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time); if (yperiod.has_value()) {