Minor: show debug output only when compiled in.

This commit is contained in:
Gerhard Hoffmann 2024-06-06 14:02:43 +02:00
parent 7492e37e02
commit 9394625d35

View File

@ -169,7 +169,11 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
// find out if we are in a pre-pay-range.
// in this case, adapt inputDate accordingly.
// #define DEBUG_GET_DURATION_FROM_COST 1
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "PRE-PAID-OPTION: ADAPT-INPUT-DATE" << inputDate.toString(Qt::ISODate);
#endif
QTime currentTime = inputDate.time();
int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
@ -218,7 +222,9 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
}
}
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "(ADAPTED) INPUT-DATE" << inputDate.toString(Qt::ISODate);
#endif
// inputDate is now located in a valid operational-working-range
// find this working-time-range
@ -250,8 +256,10 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
return "";
}
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "CURRENT WORKING-TIME-FROM" << current_working_time_from.toString(Qt::ISODate);
qCritical() << DBG_HEADER << " CURRENT WORKING-TIME-TO" << current_working_time_to.toString(Qt::ISODate);
#endif
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const pra_price = itr->second.pra_price;
@ -268,27 +276,30 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
QDateTime current_working_date_time_to = inputDate;
current_working_date_time_to.setTime(current_working_time_to);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "DURATION IN MINUTES" << duration.pun_duration;
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << duration.pun_duration * 60;
qCritical() << DBG_HEADER << "CURRENT-WORKING-DATE-TIME-TO"
<< current_working_date_time_to.toString(Qt::ISODate);
qCritical() << DBG_HEADER << "NEW INPUT DATE" << inputDate.addSecs(durationInSecs).toString(Qt::ISODate);
#endif
if (inputDate.addSecs(durationInSecs) > current_working_date_time_to) {
qCritical() << DBG_HEADER;
QTime next_working_time_from;
if (cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over != 0) {
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "CARRY-OVER SET";
#endif
// check for next working-time-range on same day
int day_in_week_id = inputDate.date().dayOfWeek();
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(day_in_week_id); iter != rEnd; ++iter) {
QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
if (pwd_time_from > current_working_time_to) {
next_working_time_from = pwd_time_from;
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "NEXT-WORKING-TIME-FROM"
<< next_working_time_from.toString(Qt::ISODate);
#endif
break;
}
}
@ -317,8 +328,12 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
lower.setTime(current_working_time_to);
inputDate = inputDate.addSecs(lower.secsTo(upper) + durationInSecs);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
#endif
break;
}
} // for (int days = 1; days < 8; ++days) {
} else { // next working-time is on same day
QDateTime upper = inputDate;
upper.setTime(next_working_time_from);
@ -327,16 +342,26 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
lower.setTime(current_working_time_to);
inputDate = inputDate.addSecs(lower.secsTo(upper) + durationInSecs);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
#endif
}
}
} else {
inputDate = inputDate.addSecs(duration.pun_duration * 60);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "INPUT-DATE" << inputDate.toString(Qt::ISODate);
#endif
}
QString const &s = inputDate.toString(Qt::ISODate);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "TICKET-END" << s;
#endif
return s.toStdString();
}
}