ComputeDurationFromCost():
Use helper function computeMinutesUntilCarryOverEnd() to compute the offset until the end of the carry-over-range.
This commit is contained in:
parent
7e2f40a7b5
commit
5e673788b4
@ -458,7 +458,7 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
|
||||
arg(cost).arg(nettoParktimeForCost);
|
||||
|
||||
int cnt = 0;
|
||||
while (++cnt < 1000 && netto_parking_time_in_minutes < nettoParktimeForCost) {
|
||||
while (++cnt < 10 && 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;
|
||||
@ -555,19 +555,21 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
|
||||
.arg(free_parking_time_in_minutes);
|
||||
|
||||
if (std::optional<ATBTariffCarryOver> co = getCarryOver(cfg, dt)) {
|
||||
TimeRange const &carryOverTimeRange = co.value().m_range;
|
||||
free_parking_time_in_minutes += carryOverTimeRange.m_duration;
|
||||
int minutes = co.value().computeMinutesUntilCarryOverEnd(dt);
|
||||
if (minutes > 0) {
|
||||
free_parking_time_in_minutes += minutes;
|
||||
|
||||
brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
|
||||
dt = inputDate.addSecs(brutto_parking_time_in_minutes * 60);
|
||||
weekDay = dt.date().dayOfWeek();
|
||||
brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
|
||||
dt = inputDate.addSecs(brutto_parking_time_in_minutes * 60);
|
||||
weekDay = dt.date().dayOfWeek();
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << QString("%1 (%2): brutto: %3 = netto: %4 + free: %5")
|
||||
.arg(dt.toString(Qt::ISODate))
|
||||
.arg(weekDay)
|
||||
.arg(brutto_parking_time_in_minutes)
|
||||
.arg(netto_parking_time_in_minutes)
|
||||
.arg(free_parking_time_in_minutes);
|
||||
qCritical() << __func__ << ":" << __LINE__ << QString("%1 (%2): brutto: %3 = netto: %4 + free: %5")
|
||||
.arg(dt.toString(Qt::ISODate))
|
||||
.arg(weekDay)
|
||||
.arg(brutto_parking_time_in_minutes)
|
||||
.arg(netto_parking_time_in_minutes)
|
||||
.arg(free_parking_time_in_minutes);
|
||||
}
|
||||
}
|
||||
|
||||
if (std::optional<ATBTariffService> serv = getService(cfg, dt)) {
|
||||
@ -577,6 +579,8 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
|
||||
int rest_parking_time_in_minutes = nettoParktimeForCost - netto_parking_time_in_minutes;
|
||||
ATBTime t(dt.time().hour(), dt.time().minute(), 0, 0);
|
||||
int timeToServiceEnd = t.secsTo(serviceTimeRange.m_end.toString(Qt::ISODate)) / 60;
|
||||
|
||||
// TODO: wohl aehnlich wie carry-over zu behandlen
|
||||
if (serviceTimeRange.m_duration > 0) {
|
||||
if (timeToServiceEnd < rest_parking_time_in_minutes) {
|
||||
netto_parking_time_in_minutes += timeToServiceEnd;
|
||||
|
Loading…
Reference in New Issue
Block a user