Moved check if netto minutes exceed max. parking time down into loop.

If this is the case, then stop updating the end-time-date.
This commit is contained in:
Gerhard Hoffmann 2024-02-01 13:19:08 +01:00
parent 38eca50d83
commit 9d713c894d

View File

@ -707,10 +707,16 @@ Ticket Calculator::private_GetDurationFromCost(Configuration *cfg,
if (!IsYearPeriodActive(cfg, current)) { if (!IsYearPeriodActive(cfg, current)) {
return Ticket(); return Ticket();
} }
if(durationMinutesNetto > maxParkingTimeMinutes) { // if(durationMinutesNetto >= maxParkingTimeMinutes) {
durationMinutesNetto = maxParkingTimeMinutes; // might be useful for overpayment
break; // durationMinutesNetto = maxParkingTimeMinutes;
} // int durationMinutesBrutto = start.secsTo(end) / 60;
//
// return
// Ticket(start, end, durationMinutesNetto,
// durationMinutesBrutto, cost, Ticket::s[INVALID_PRICE]);
//
// }
if(current.time() >= lastWorktimeTo) { if(current.time() >= lastWorktimeTo) {
// Go to next day if minutes not spent // Go to next day if minutes not spent
if (carryOverNotSet) { if (carryOverNotSet) {
@ -722,11 +728,20 @@ Ticket Calculator::private_GetDurationFromCost(Configuration *cfg,
} else { } else {
if(current.time() < worktime_to) { if(current.time() < worktime_to) {
// Increment input date minutes for each monetary unit // Increment input date minutes for each monetary unit
durationMinutesNetto +=1; durationMinutesNetto += 1;
moneyLeft -= price; moneyLeft -= price;
moneyLeft = std::round(moneyLeft * 1000.0) / 1000.0; moneyLeft = std::round(moneyLeft * 1000.0) / 1000.0;
current = current.addSecs(60); current = current.addSecs(60);
end = current;
//qCritical() << "moneyLeft" << moneyLeft
// << "durationMinutesNetto" << durationMinutesNetto
// << "current" << current.toString(Qt::ISODate);
if(durationMinutesNetto <= maxParkingTimeMinutes) {
// stop updating of end-date if parking time is
// overshot
end = current;
}
} else break; } else break;
} }
} // while(durationMinutes > 0) { } // while(durationMinutes > 0) {
@ -734,7 +749,7 @@ Ticket Calculator::private_GetDurationFromCost(Configuration *cfg,
} // for (int w = currentRange; w < ranges; ++w, ++totalTimeRanges) { } // for (int w = currentRange; w < ranges; ++w, ++totalTimeRanges) {
} // for (current = start; durationMinutes > 0; current = current.addDays(1)) { } // for (current = start; durationMinutes > 0; current = current.addDays(1)) {
int durationMinutesBrutto = start.secsTo(end) / 60; int durationMinutesBrutto = start.secsTo(end) / 60;
//qCritical() << "start" << start.toString(Qt::ISODate) << "end" //qCritical() << "start" << start.toString(Qt::ISODate) << "end"
// << end.toString(Qt::ISODate) << durationMinutesBrutto; // << end.toString(Qt::ISODate) << durationMinutesBrutto;